MediaPlayer Error

sarim123

Member
Licensed User
Longtime User
Im getting a null pointer error on my phone when i hit stop and when i change the volume for the music, i have no clue why.
Here is the error for the stop button
B4X:
An error has occured in
sub:page2_button69_click(java line:
347)
java.lang.NullPointerException
Continue?

Here is for the volume

B4X:
An error has occured in
sub:page2_barvolume_valuechanged(java line:
260)
java.lang.NullPointerException
Continue?


Here is the project

https://www.dropbox.com/s/xeprj5s3j8ot989/Sounds.zip
Thanks
 

stevel05

Expert
Licensed User
Longtime User
This is because you are trying to stop a mediaplayer object, or change it's volume before you have initialized it.

If you play all of the sounds first the error doesn't happen. You could move all of the initializations to the activity create.
 
Upvote 0
Top