I want to play 5 songs together without any miss sync. I've taken reference from the below link with use of NDK:
https://github.com/googlesamples/android-ndk
I'm creating 5 instance for player and playing songs but on some devices songs are not played in sync when I just fire a play.
I would like to know what is the best way to achieve this so I can play multiple songs in sync.
Let me inform you the device having good configuration like 2gb+ RAM will play sounds in perfectly But in device having RAM of 1GB will not work always.
I've tried with MediaPlayer and Soundpool but not helps me. NDK implementation is far better.
Looking for best work around for this...
Thanks in advance
you should use sound pool here is an example how to use it:
https://examples.javacodegeeks.com/android/android-soundpool-example/
Related
I'm trying to make a radio app. Everything is ok, except playing radios. I'm getting play link from a page with Jsoup. When i press play, (in real device)it takes 40-50 seconds to start playing. But in genymotion device (Google Nexus 4- 4.4.4- API 19) it takes just 3-4 second. I couldn't find what is wrong.
I'm new on Android and I couldn't find a solution for days. Thanks id advance.
I really recommend you to use google exo player instead of default android player for streaming. its too fast and you will never have problems like this.
https://github.com/google/ExoPlayer
You must try it without emulator, as they themselves are slow.
Also give below links a read.
https://developer.android.com/reference/android/media/AudioManager.html
https://developer.android.com/guide/topics/media/mediaplayer.html
For Best performance native is good:
https://developer.android.com/ndk/guides/audio/index.html
So I have an app that plays a video.
And I have a time sync server for setting the datetime of the device. It seems that whenever I call SystemClock.setCurrentTimeMillis(millis) the video stops.
I am using android.media.MediaPlayer.MediaPlayer() object to play the video?
Has anyone else experienced this? I was planning on creating a watchdog thread that just monitors the current duration. But just wanted to know if anyone had come across this already?
Yes, I came across the same situation on some devices. Probably hardware libs use the system time clock in the in decoding or av sync implementation; it happens. Only solution on those devices was to stop/restart the MediaPlayer. But it probably depends on the implementation of the lower levels.
I am doing a cards game for android and I want that everytime a card is thrown, to play throwing sound. It is the same file. I will have also other sounds playing like background music , and certain clicks.
What do you recommend to use, sound pool or create MediaPlayback and play it? What would be the advantage/disdvantage to each one? should I use ogg or mp3/wave file?
Any help in this is appreciated.
Thank you
I would use the sound pool for short clips. I might be wrong but the sound pool has a smaller overhead plus it's the correct way to play short clips, it also allows you to specify how many times per second said sound clip can play which helps slower phones.
With regards to the mp3 vs ogg I use mp3. I don't believe there is any performance issues. Ogg is licence free but that doesn't really matter with regards to your app. Plus it might help if you plan on using these clips on another platform that doesn't play ogg files. No names mentioned :P
I'd like to know how I can call a video from an external server database and play it in android? any helpful tutorials?
another question, when I play my video in emulator is it normal that it gives me a low quality and plays very slow..like moving in slow motion?
Emulators not responded quickly while you are playing video.I hope you understand that.
I need to be able to have multiple tracks playing at the same time, and also changing to other tracks with as little latency as possible. I don't think SoundPool will work, since it are real audiotracks and not so much samples. I'm trying to make like some sort of mixing application, where you can select certain tracks to play, and others not to play.
Any idea on how to do this, suggestions/tips ?