Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle cell stations switches. #2852

Closed
russrizo opened this issue May 21, 2017 · 1 comment
Closed

Handle cell stations switches. #2852

russrizo opened this issue May 21, 2017 · 1 comment

Comments

@russrizo
Copy link

russrizo commented May 21, 2017

Issue description

There is a problem with playing stream radio(Icecast backend). It appears while phone switches cell stations. Audio stops playing. On the other hand If I switch off and then switch on WiFi audio playback stops but then starts again. It happens only on mobile data. Also interesting thing that playback stops immediately on WiFi toggle, I was sure that it should continue playing from buffer till it ends.
Icecast station url: http://hitfm.kz/mp3/URBAN
Here is my code

MediaSource mediaSource;
  ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
  Handler mHandler;
  SimpleExoPlayer mPlayer;
  public UnderExoMediaPlayer(Context context) {
        mHandler = new Handler();
        TrackSelection.Factory videoTrackSelectionFactory = new FixedTrackSelection.Factory();
        TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
        DefaultAllocator allocator = new DefaultAllocator(true, 256);
        LoadControl loadControl = new DefaultLoadControl(allocator, 25000, 30000, 1000, 5000); // 
  min buffer, max buffer, start buffer, resume buffer
        mPlayer = ExoPlayerFactory.newSimpleInstance(context, trackSelector, loadControl);
        dataSourceFactory = new DefaultHttpDataSourceFactory(
                Util.getUserAgent(context, "myRadio"), new TransferListener<DataSource>() {
            @Override
            public void onBytesTransferred(DataSource source, int bytesTransferred) {
                if(!ready && ExoPlayer.STATE_READY == mPlayer.getPlaybackState()){
                    if(mOnPreparedListener != null) {
                        new Handler(Looper.getMainLooper()).post(new Runnable() {
                            @Override
                            public void run() {
                                mOnPreparedListener.onPrepared();
                            }
                        });
                    }
                    ready = true;
                }
            }
        });
    }
  public void setDataSource(final Context context, Uri uri) {

        mPlayer.setPlayWhenReady(false);
        mediaSource = new ExtractorMediaSource(uri, dataSourceFactory, extractorsFactory, 
  mHandler, new ExtractorMediaSource.EventListener() {
            @Override
            public void onLoadError(IOException error) {
               mPlayer.prepare(mediaSource);
            }
        });
    }

How can I fix this behavior?

Reproduction steps

Sit in the car, listen to the radio and drive around blocks

Version of ExoPlayer being used

Exoplayer:r2.2.0

Device(s) and version(s) of Android being used

Problem appears on all devices. In my case it is Google Pixel

@ojw28
Copy link
Contributor

ojw28 commented May 22, 2017

Playing out the remaining buffer rather than stopping immediately for this use case is tracked by #1606. For the "stopping" case, you haven't provided sufficient information for us to tell what happened. Please supply a full bugreport as requested in the issue template, captured shortly after encountering the failure.

@ojw28 ojw28 closed this as completed May 22, 2017
@google google locked and limited conversation to collaborators Sep 20, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants