Android Question MediaPlayer problem (BMC-game )

MasterGy

Member
Hello!

The game is done. It may need minor tweaks, but it's basically done. With or without VR glasses, it provides 10-20 minutes of enjoyment. You can't die, the game tries to go for the experience and complete the unconditional mission.

I think I understood in which cases multi-threading should be used. Although I think the name is misleading, it is obviously not a parallel run. I asked not long ago, but no one explained it sensibly. I used 'thread' for 'set_texture_filter'. good, because converting an image takes a long time, and while it is calculating, the user must be able to modify the interface. I understood that. However, my personal experience is that it is completely unnecessary to use 'thread' and the like with opengl programs. The main interface that the user is curious about and waiting for is the graphics itself. It is unnecessary to divide it into parts here.

I have included many things in the game. You can also use vr glasses while sitting. There are several control options available.
The lighting conditions and the brightness of the phone display are given. obviously you can't change it. I have included a texture filter where you can adjust light/contrast/sharpness, etc. The game has real textures. This way you can play even in poor lighting conditions.

The story of the game is that first you have to find the princess, she gets two chocolates, then you have to go through the labyrinths, and the chocolate is in the last one. Entrances to labyrinths require monsters. Monsters travel in UFOs...

My problem that won't go away:

MEDIA PLAYER

It doesn't work correctly for either this game or the previous game. I test it on 3 different Android phones, all of them make the same mistake. There are no sounds. I use the very short sounds in wav, the long ones in mp3. Sometimes it plays, sometimes it doesn't. The system does not indicate an error. Never error feedback. I'm going crazy because I've tried everything. For example, I initialize it once and load it several times. I either use delays, or when loading I check with simulated playback to see if it plays, or I read the 'duration'. it loads it as if everything is fine, then it either plays it while playing or it doesn't .

Questions:
-I would stick to mediaplayer, because it is part of Android, and I read about soundpool that not all systems are reliable

-how can I check when loading the sound file whether it will play the sound when it is needed. even though I tried simulated playback in the loading section as a back check, it doesn't notice.

I'm at a complete loss as to how to handle the sounds. The game loses its enjoyment value if sounds are missing. and at all...what is it that sometimes it plays and sometimes it doesn't?

 

zed

Active Member
Licensed User
SoundPool is a great choice. Here you can have an example of how to use sound pool by combining IDs and objects.
 
Upvote 0

MasterGy

Member
SoundPool is a great choice. Here you can have an example of how to use sound pool by combining IDs and objects.
Thanks for the answer! I've changed all tunes under 5 seconds from mediaplayer to soundpool. Works well, doesn't make any sounds. Plays all notes. I like that the playback speed is adjustable. Unfortunately, however, the soundpool greatly slows down the system. I miss the fact that it is not possible to retrieve the length of the sound and the current position. Other than that it works great. The point is that it solved my problem!

Thank you very much!
 
  • Like
Reactions: zed
Upvote 0

zed

Active Member
Licensed User
Soundpool is generally used for short sounds. This is why you don't have the time and the position.

You can also play several sounds at the same time
 
Upvote 0

MasterGy

Member
Soundpool is generally used for short sounds. This is why you don't have the time and the position.

You can also play several sounds at the same time
Soundpool is really good, because I can load a sound file and multiply it, and I don't have to deal with it after the 'play' is released. I often tie the life of a process to the position of an audio file. another case, for example, a new shout cannot follow until the previous one is heard. A dragon cannot roar in pain while breathing fire. So far, I have read these conditions from the mediaplayer. here the thought process had to be modified a bit, but overall it is good to use.
 
  • Like
Reactions: zed
Upvote 0

MasterGy

Member
it worked, soundpool still works great after a lot of testing. The long sounds (background music) is performed by the service module, so it has become reliable. There are also some threads in it, I'm starting to understand.

This android is interesting. For example, I ran into errors for a long time because I thought things ran linearly, one after the other.

But the recognition that, for example, if from one module, we start another activity module (startactivity), and the fact that the current activity does not stop afterwards... (so no 'goto'... already no 'goto'). there are parallel threads here, and care must be taken to ensure that they run harmoniously with each other, conflicts of interest must be ruled out. In fact, parallel threads must sometimes be used! The system requires a completely different logic than I thought before I started dealing with android. It's a different world after dos-basic :)


 
  • 100%
Reactions: zed
Upvote 0

zed

Active Member
Licensed User
The only problem you'll encounter with Android is Google's restrictions.
Otherwise, the lib' and code snippet are all reliable.
And there will always be someone to help you.
 
Upvote 0
Top