MP.Play

omoba

Active Member
Licensed User
Longtime User
Hi,

When a button is clicked the following below happens (Code)

Sub Button1_Click

Number1 = Rnd(432,995)

ImageView1.bitmap=LoadBitmap(File.DirAssets,"m2_000" & Number1 & ".bmp")
MP.Initialize
MP.Load(File.DirAssets,"m2_000" & Number1 & ".wav")
MP.Play

End Sub


Ok this works fine; image is displayed and audio plays. Now if the Button is clicked when the audio is still playing, another image shows and new audio.

The problem is that I dont want multiple audios playing at a time; I want previous audio to stop and the new one starts. I have tried MP.Stop and MP.Release but to no avail (maybe I am putting them in the wrong place)

Pls help
 

spillo3d96

Member
Licensed User
Longtime User
You can try to use:

If MP.IsPlaying Then
MP.Stop
MP.Load(File.DirAssets,"m2_000" & Number1 & ".wav")
MP.Play
End if
 
Upvote 0

omoba

Active Member
Licensed User
Longtime User
I get a java.lang.NullPointerException error
Error line 312 in my code


If (mostCurrent._mp.IsPlaying()) {
//BA.debugLineNum = 74;BA.debugLine="MP.Stop";
mostCurrent._mp.Stop();
};

And doesnt play any audio
 
Last edited:
Upvote 0

omoba

Active Member
Licensed User
Longtime User
Fixed

Problem Solved.
I was initially initializing MP upon entering the sub; I guess it didn't like that.
So I initialize only in Sub Activity_Create(FirstTime As Boolean)

Sub Button1_Click

If MP.IsPlaying Then
MP.Stop
End If

Number1 = Rnd(432,995)
MP.Load(File.DirAssets,"m2_0" & Number1 & ".wav")
MP.Play
End sub
 
Upvote 0
Top