Hey guys, one question..
i was writing small mediaplayer procedure for playing small wav mp3 ... files like "tada, bling... etc"
the idea was when user presses command button it also plays this short - 1 second sound.
my "player" went into "code module" and it was like this:
it worked ok, problem was when user fast pressed button several times, media player stopped working until i restarted a program.
after some trial and error rewrote my sub like this. (we are still in "code module")
and here is my question: i'm missing "mediaplayer.IsInitialized" property. Did i went wrong about this player? what do you use for playing small "tadaaa" sounds in jour app?
ps: this is not a game i'm making, just an app for company i work for...
i was writing small mediaplayer procedure for playing small wav mp3 ... files like "tada, bling... etc"
the idea was when user presses command button it also plays this short - 1 second sound.
my "player" went into "code module" and it was like this:
B4X:
Sub PlayFile2(sndFileName As String)
Dim myPlayer As MediaPlayer
myPlayer .Load(File.DirAssets,sndFileName)
Player.Play
End Sub
it worked ok, problem was when user fast pressed button several times, media player stopped working until i restarted a program.
after some trial and error rewrote my sub like this. (we are still in "code module")
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private Player As MediaPlayer ' <- player obj
Private PlayerIni As Boolean ' <- variable for checking initialization
End Sub
Sub PlayFile(sndFileName As String)
If Not(PlayerIni) Then
PlayerIni=True
Player.Initialize()
End If
If Player.IsPlaying Then
Player.stop
End If
Player.Load(File.DirAssets,sndFileName)
Player.Play
End Sub
and here is my question: i'm missing "mediaplayer.IsInitialized" property. Did i went wrong about this player? what do you use for playing small "tadaaa" sounds in jour app?
ps: this is not a game i'm making, just an app for company i work for...