vbartacek / aacdecoder-android

Automatically exported from code.google.com/p/aacdecoder-android
GNU Lesser General Public License v3.0
119 stars 58 forks source link

Unable to stop the multiplayer while loading -Very critical issue #67

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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 bpvela...@gmail.com on 17 Sep 2014 at 4:27

GoogleCodeExporter commented 9 years ago
Issue happends most of the time while stopping the streaming while buffering.

Original comment by bpvela...@gmail.com on 17 Sep 2014 at 4:29

GoogleCodeExporter commented 9 years ago
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 amf...@gmail.com on 19 Sep 2014 at 2:08

GoogleCodeExporter commented 9 years ago
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 sepasgr...@gmail.com on 5 Oct 2014 at 1:29

GoogleCodeExporter commented 9 years ago
You can implement PlayerCallback as per the aacdecoder wiki

Original comment by bij...@phenomtec.com on 7 Oct 2014 at 9:16

GoogleCodeExporter commented 9 years ago
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 sepasgr...@gmail.com on 16 Oct 2014 at 1:11

kraizman commented 9 years ago

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);
        }
    }
Informatheus commented 9 years ago

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:

I hope some improvements in the future:

Anyway, this lib is very good and very usefull. Thanks;

airstep commented 9 years ago

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)

airstep commented 9 years ago

Nevermind, found fix at: https://github.com/mtakemi/aacdecoder-android