TGC Codebase Backup



Audio CD Player by Anonymous Coder

7th Nov 2004 17:04
Summary

This is an improvement of a same earlier application , without unnecessary text information , and some minor bugs eliminated.



Description

1.Documentation attached , with all essential information.
2.Executable attached.

May anyone please post a plug-in or any other tools you may have , as well as installation explanations?

Thank you.

Feel free doing anything you want with the application , documentation and source code.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    Rem Project: Audio CD Player
Rem Created: 7/11/2004 11:31:59 πμ

Rem ***** Main Source File *****

Rem Project: Audio CD Player for Laszlo Zoltan
Rem Created: 4/11/2004 9:19:32 μμ

Rem ***** Main Source File *****

global track_duration_switch$="on"
global song_duration_sec=0
global song_duration_min=0
global time=0
global automatic_play_cd_first_time$="yes"

global Music_Number=1
global current_track=0
global proceed$="no"
global cd_tracks=0
global repeat$="Yes"
global status$="Stopped"

global rightkey$="free"
global leftkey$="free"
global upkey$="free"
global downkey$="free"

SET WINDOW ON
SET WINDOW TITLE "Audio CD Player"
show window
minimize WINDOW

audio_cd()

if (proceed$="yes")
   do
      cls
      cd_tracks=GET NUMBER OF CD TRACKS()
      cursor_reader()
      update_music_sequence()
      track_duration_routine()
      screen_info()
   loop
endif
end

function update_music_sequence()

if (automatic_play_cd_first_time$="yes")
   if (status$="Stopped")
      if (MUSIC PLAYING(Music_Number)=0)
         if (current_track=1)
            loadandplay_audio_CD("play")
            automatic_play_cd_first_time$="no"
         endif
      endif
   endif
endif

if (status$="Playing")
   if (MUSIC PLAYING(Music_Number)=0)
      if (current_track <> cd_tracks)
         current_track=current_track+1
         loadandplay_audio_CD("play")
         track_duration("off")
         track_duration("on")
         automatic_play_cd_first_time$="no"
      endif
   endif
endif

if (status$="Playing")
   if (repeat$="Yes")
      if (current_track=cd_tracks)
         if (MUSIC PLAYING(Music_Number)=0)
            current_track=1
            loadandplay_audio_CD("play")
            track_duration("off")
            track_duration("on")
            automatic_play_cd_first_time$="no"
         endif
      endif
   endif
endif

if (status$="Playing")
   if (repeat$="No")
      if (current_track=cd_tracks)
         if (MUSIC PLAYING(Music_Number)=0)
            current_track=1
            loadandplay_audio_CD("stop")
            track_duration("off")
            automatic_play_cd_first_time$="no"
         endif
      endif
   endif
endif


endfunction


function locate_track(command$)
if (command$="forward")
   if (status$="Playing")
      if (current_track <= cd_tracks)
         current_track=current_track+1
         loadandplay_audio_CD("play")
         track_duration("off")
         track_duration("on")
      endif
      if (current_track > cd_tracks)
         current_track=1
         loadandplay_audio_CD("play")
         track_duration("off")
         track_duration("on")
      endif
   else
      current_track=current_track+1
   endif
endif

if (command$="backward")
   if (status$="Playing")
      if (current_track >=1 )
         current_track=current_track-1
         loadandplay_audio_CD("play")
         track_duration("off")
         track_duration("on")
      endif
      if (current_track < 1)
         current_track=cd_tracks
         loadandplay_audio_CD("play")
         track_duration("off")
         track_duration("on")
      endif
   else
      current_track=current_track-1
   endif
endif

if (current_track<1)then:current_track=cd_tracks
if (current_track>cd_tracks)then:current_track=1
if (command$="play") then: loadandplay_audio_CD("play")
if (command$="stop") then: loadandplay_audio_CD("stop")
if (command$="loop") then: repeat_audio_CD("loop")
if (command$="noloop") then: repeat_audio_CD("noloop")
endfunction

function repeat_audio_CD(command$)
if (command$="loop")
   if (repeat$="No")
      repeat$="Yes"
   endif
endif

if (command$="noloop")
   if (repeat$="Yes")
      repeat$="No"
   endif
endif
endfunction


function loadandplay_audio_CD(command$)
private_current_track$="null"

if (current_track >=1)
   if (current_track <= cd_tracks)
      private_current_track$="valid"
      delete music Music_Number
      LOAD CDMUSIC current_track,Music_Number
   endif
endif

if ( private_current_track$="valid")
   if (command$="play")
      if (MUSIC PLAYING(Music_Number)=0)
         delete music Music_Number
         LOAD CDMUSIC current_track,Music_Number
         PLAY MUSIC Music_Number
         status$="Playing"
      endif
   endif

   if (command$="stop")
      if (MUSIC PLAYING(Music_Number)=0)
         stop music Music_Number
         status$="Stopped"
      endif
   endif
else
   if ( private_current_track$="invalid")
      EXIT PROMPT "Invalid audio CD track.", "Error"
      proceed$="no"
   endif
endif
endfunction

function audio_cd()
if (GET NUMBER OF CD TRACKS()=0)
   EXIT PROMPT "No audio CD.", "Error"
   proceed$="no"
else
   proceed$="yes"
   cd_tracks=GET NUMBER OF CD TRACKS()
   current_track=1
   LOAD CDMUSIC current_track,Music_Number

endif
endfunction

function screen_info()
set cursor 0,0:  print "CD Tracks: ",cd_tracks
set cursor 0,15: print "Current Track: ",current_track
set cursor 0,30: print "Repeat Audio CD: ",repeat$
set cursor 0,45: print "Status: ",status$
set cursor 0,60: print "Song Duration: ",song_duration_min,":",song_duration_sec
endfunction

function cursor_reader()

if (rightkey()=1)
   if (rightkey$="free")
      locate_track("forward")
      rightkey$="lock"
   endif
endif

if (leftkey()=1)
   if (leftkey$="free")
      locate_track("backward")
      leftkey$="lock"
   endif
endif

if (downkey()=1)
   if (downkey$="free")
      if (status$="Playing")
         locate_track("stop")
      else
         locate_track("play")
      endif
   downkey$="lock"
   endif
endif

if (upkey()=1)
   if (upkey$="free")
      if (repeat$="Yes")
         locate_track("noloop")
      else
         locate_track("loop")
      endif
   upkey$="lock"
   endif
endif

if (keystate(scancode())=0)
   rightkey$="free"
   leftkey$="free"
   upkey$="free"
   downkey$="free"
endif
endfunction


function track_duration_routine()
if (status$="Playing")
   track_duration("on")
endif
if (status$="Stopped")
   track_duration("off")
endif
endfunction

function track_duration(command$)
if (command$="on")
   if ( track_duration_switch$="on")
      time=timer()
      track_duration_switch$="off"
   endif
endif

if ( command$="off")
   song_duration_sec=0
   song_duration_min=0
   track_duration_switch$="on"
endif

if ( status$="Playing")
   song_duration_sec=(timer()-time)/1000
   if (song_duration_sec>=60)
      song_duration_min=song_duration_min+1
      song_duration_sec=0
      time=timer()
   endif
endif
endfunction