// Project Example: GetMusicDuration()
// Created: 2015-02-04 (updated for Windows and Android)
//NOTE: For this example to work you will need to copy 'music.mp3'
//to the media folder at the location where you are running this example.
//The file can be found in your [AGK Install Directory]/Projects/Basic/Examples/Sound/PlayingMusic/media/
Setvirtualresolution(640,480)
ResetTimer()
//Check for required files in media folder
fileok=GetFileExists("music.mp3")
If fileok<>1
Repeat
Print ("music.mp3 needs to be in your media folder")
Sync()
Until Timer()>5
EndIF
If fileok=1
AddVirtualButton(1,200,240,80)
SetVirtualButtonText(1,"Pause")
AddVirtualButton(2,400,240,80)
SetVirtualButtonText(2,"Resume")
AddVirtualButton(3,600,440,80)
SetVirtualButtonText(3,"Quit")
id = LoadMusic("music.mp3")
PlayMusic(id)
Repeat
duration#=GetMusicDuration(id)
Print("Music Play Length: "+Str(duration#)+" Seconds")
If GetVirtualButtonPressed(1)
PauseMusic()
EndIf
If GetVirtualButtonPressed(2)
ResumeMusic()
EndIf
Sync()
Until GetVirtualButtonPressed(3) OR Timer()>duration#
DeleteMusic(1)
Print ("Music Deleted")
Sync()
Sleep(2000)
EndIf
End
Help make AGK better by submitting an example for this command! (All examples are subject to approval)
// Project Example: GetMusicDuration() // Created: 2015-02-04 (updated for Windows and Android) //NOTE: For this example to work you will need to copy 'music.mp3' //to the media folder at the location where you are running this example. //The file can be found in your [AGK Install Directory]/Projects/Basic/Examples/Sound/PlayingMusic/media/ Setvirtualresolution(640,480) ResetTimer() //Check for required files in media folder fileok=GetFileExists("music.mp3") If fileok<>1 Repeat Print ("music.mp3 needs to be in your media folder") Sync() Until Timer()>5 EndIF If fileok=1 AddVirtualButton(1,200,240,80) SetVirtualButtonText(1,"Pause") AddVirtualButton(2,400,240,80) SetVirtualButtonText(2,"Resume") AddVirtualButton(3,600,440,80) SetVirtualButtonText(3,"Quit") id = LoadMusic("music.mp3") PlayMusic(id) Repeat duration#=GetMusicDuration(id) Print("Music Play Length: "+Str(duration#)+" Seconds") If GetVirtualButtonPressed(1) PauseMusic() EndIf If GetVirtualButtonPressed(2) ResumeMusic() EndIf Sync() Until GetVirtualButtonPressed(3) OR Timer()>duration# DeleteMusic(1) Print ("Music Deleted") Sync() Sleep(2000) EndIf End