I'm trying to use MediaPlayer, but an't seem to get it to work. The app is o play a series of mp3 files in order and, therefore, I am using a Complete event to control the whole process (MP_Complete). NOTE: There is a section of the app that displays the text content of the mp3 files. Both Activities use the same process. The text alone is working precisely as it should. Therefore, the basic logic of the process seems to be acceptable, even if it's not elegent.
I've used Initialize2 as follows from within Sub Init:
MP.Initialize2("MP_Complete")
SM = False
SM = StartMsg
SCFlag = False
The app waits for the user to start the process by tapping the screen, which raises a pnlST_Clicck event, which calls MP_Complete for the first time to get the name of the first audio file.
Sub pnlST_Click
If (SM = True) AND (MPfile = "") Then
MP_Complete
End If
End Sub
Sub MP_Complete assigns the file name to MPfile and then further down in the sub, calls the sub that actually loads and plays the file. The Log is used to indicate whether MP_Complete has been called; if so Tmp wiill show 0, if not the Log will not be written. The sub that plays the audio, sets Tmp to 1 so that when MP_Complete is called again at the end of the playing audio, the Log will be written showing 1
Sub MP_Complete
Log("Tmp = " & Tmp)
MPfile = "file1.mp3"
.
.
.
ShowST
MP.Release
'Code to advance to the next mp3 file.
End Sub
ShowST is called to play the file:
Sub ShowST
MPfile = MPfile & PrLn & ".mp3"
Log("MPfile = " & MPfile)
If MPfile <> "sc_0.mp3" Then
Activity.Finish
End If
MP.Load(File.DirAssets, MPfile)
MP.Play
If MP.IsPlaying = True Then
Log("MP is playing")
Else
Log("MP is NOT playing")
End If
End Sub
PrLn is a conter that increments in the MP_Complete event (the mp3 file names use a prefix followed by a number and ".mp3" I've used the Log entries to try to determine where and possibly why things are going wrong. These show:
Tmp = 0
MPfile = sc_0.mp3
MP is playing
What happens is this. At the point when the first file is supposedly playing, there is no sound and the program stalls without displaying an error. So, I need some help determing what is wrong and how to correct it. Thanks.
I've used Initialize2 as follows from within Sub Init:
MP.Initialize2("MP_Complete")
SM = False
SM = StartMsg
SCFlag = False
The app waits for the user to start the process by tapping the screen, which raises a pnlST_Clicck event, which calls MP_Complete for the first time to get the name of the first audio file.
Sub pnlST_Click
If (SM = True) AND (MPfile = "") Then
MP_Complete
End If
End Sub
Sub MP_Complete assigns the file name to MPfile and then further down in the sub, calls the sub that actually loads and plays the file. The Log is used to indicate whether MP_Complete has been called; if so Tmp wiill show 0, if not the Log will not be written. The sub that plays the audio, sets Tmp to 1 so that when MP_Complete is called again at the end of the playing audio, the Log will be written showing 1
Sub MP_Complete
Log("Tmp = " & Tmp)
MPfile = "file1.mp3"
.
.
.
ShowST
MP.Release
'Code to advance to the next mp3 file.
End Sub
ShowST is called to play the file:
Sub ShowST
MPfile = MPfile & PrLn & ".mp3"
Log("MPfile = " & MPfile)
If MPfile <> "sc_0.mp3" Then
Activity.Finish
End If
MP.Load(File.DirAssets, MPfile)
MP.Play
If MP.IsPlaying = True Then
Log("MP is playing")
Else
Log("MP is NOT playing")
End If
End Sub
PrLn is a conter that increments in the MP_Complete event (the mp3 file names use a prefix followed by a number and ".mp3" I've used the Log entries to try to determine where and possibly why things are going wrong. These show:
Tmp = 0
MPfile = sc_0.mp3
MP is playing
What happens is this. At the point when the first file is supposedly playing, there is no sound and the program stalls without displaying an error. So, I need some help determing what is wrong and how to correct it. Thanks.
Last edited: