aacdecoder-android
aacdecoder-android copied to clipboard
Unable to stop the multiplayer while loading -Very critical issue
Due to network issue the streaming may take to much time to buffer and at that
time when we tried to stop the player the multiplayer will be out of control
and need to foreclose the application from app manager in the android.
What steps will reproduce the problem?
1. Boolean Flag for playing and stopping and loading status.
2. Force stop the service using the multiplayer.
3. Called Multiplayer stop and equal to null to stop the playing
What is the expected output? What do you see instead?
When clicking the stop button the player should be stopped, But player will out
of control and it will not stop.
What version of the product are you using? On which device ?
Android devices in most of the version from 2.3 to 4.4.2
Original issue reported on code.google.com by [email protected]
on 17 Sep 2014 at 4:27
Issue happends most of the time while stopping the streaming while buffering.
Original comment by [email protected]
on 17 Sep 2014 at 4:29
I have manage this issue by locking the stop button until it totally started to
play or returns error. I hope you could figure out this way.
Original comment by [email protected]
on 19 Sep 2014 at 2:08
Hi,
How do you know "it totally started" ??
i tried a lot of things but i didn't succeed :/
thanks in advance,
Original comment by [email protected]
on 5 Oct 2014 at 1:29
You can implement PlayerCallback as per the aacdecoder wiki
Original comment by [email protected]
on 7 Oct 2014 at 9:16
Thanks a lot.
I've already implement a PlayerCallBack but i guess my tests were not Ok so i
try another way to fast ^^
Is it better to use the boolean playerStarted in the playerStarted() method or
is it better to do the vérification in the playerPCMFeedBuffer with the
boolean isPlaying ?
Thanks ;)
Original comment by [email protected]
on 16 Oct 2014 at 1:11
I have another solution. I belie i solved it with small patch and a fact that i start new player instance every time i need to play stream from start. I must admit that this solution isn't grate but it work. Bottom line is that player that stuck on loading will just stop as soon as it released from loading. This happens because i don't return stopped
to false
as it done in original implementation
So patch is just small change inside AACPlayer.java
So instead this:
public final void play( InputStream is, int expectedKBitSecRate ) throws Exception {
stopped = false;
if (playerCallback != null) playerCallback.playerStarted();
if (expectedKBitSecRate <= 0) expectedKBitSecRate = DEFAULT_EXPECTED_KBITSEC_RATE;
sumKBitSecRate = 0;
countKBitSecRate = 0;
playImpl( is, expectedKBitSecRate );
}
I made this:
public final void play( InputStream is, int expectedKBitSecRate ) throws Exception {
if(!stopped) {
if (playerCallback != null)
playerCallback.playerStarted();
if (expectedKBitSecRate <= 0)
expectedKBitSecRate = DEFAULT_EXPECTED_KBITSEC_RATE;
sumKBitSecRate = 0;
countKBitSecRate = 0;
playImpl(is, expectedKBitSecRate);
}
}
Im facing the same issue, cause despite im blocking the button after the click, my player needs a time limit for buffering attempt and it also haves a cancel button on buffering dialog. When one happen, i do use mPlayer.stop() but it stil buffering and then i almost lose the control of the player. For those here having another problems, i suggest some tips:
- button.setClickable(false) [or setEnabled(false)] right after onClick();
- button comes enabled again after the buffering is complete OR the player is stopped (exception);
- instead of using a boolean flag to know when playing, manage a ENUM flag with the positions STOPPED, PLAYING and BUFFERING;
- flag turns buffering in playerStarted() or when you call playAsync() on player, you decide;
- flag turns playing in playerAudioTrackCreated(), here you detect that the buffering is complete;
- it might be advisable to call playerStopped(int) right after you call mPlayer.stop() instead of waiting for the callback;
- to avoid some headaches about the previous item, verify if status != stopped before enter in onPlayerStopped() method, if stopped, dont execute the method content;
I hope some improvements in the future:
- the possibility of cancel buffering;
- know from the player if status is stopped, buffering or playing;
- set in player a time limit for connection attempt, so if this time reaches, the player itself throws the exception by this reason;
- add the lib on gradle;
Anyway, this lib is very good and very usefull. Thanks;
Hi!
Prepared quick example: https://github.com/airstep/AACRadioPlayer
If you push start button too fast - player will be out of the control and we can't stop pervious opened streams !!! How to fix this issue?
Binary apk for test: http://tgsoft.in/work/radio_player_6.apk
For installation: adb install radio_player_6.apk
Reproduction: click start button very fast (10 times)
Nevermind, found fix at: https://github.com/mtakemi/aacdecoder-android