Android Brightcove onVideo does not get called sometimes and hence video does not play

484 views Asked by At

I have integrated Brightcove android-sdk-4.2.7 and trying to play video using videoID.

Here is the code snippet :

Catalog catalog = new Catalog(<**MEDIA_READ_TOKEN**>);
catalog.findVideoByID(videoId, new VideoListener() {
@Override
public void onError(String error) {
    Log.e(TAG, "onError : " + error);
}
@Override
public void onVideo(Video video) {
    Log.i(TAG, "onVideo called" );
    brightcoveVideoView.add(video);
    brightcoveVideoView.start();
}
});

When I launch video_player_activity from other activity for the first time video plays perfectly fine, but when I go back to second activity and again try to play the same/other video, It does not play. onVideo does not get called. Sometimes it gets called after a long time.

Following are some more details :

  1. activity is getting destroyed properly when I go back
  2. onError is not getting called
  3. video id is getting set properly
  4. Tried emitter events and READY_TO_PLAY event occurs but DID_PLAY does not
  5. Android version I tested on is 4.4.x

What might be the possible issues? Any help/pointer around this will be really appreciated.

Thanks!

1

There are 1 answers

1
Paul Reilly On

Repeated calls to findVideoByID(), should work fine. For each one, you should see a request in the logcat, something like:

D/HttpService(27297): issuing GET request: http://api.brightcove.com/services/library?command=find_video_by_id&video_id=3603631382001...

and a response, something like:

D/HttpService(27297): response: {"id":36036...

If that is not the case, please file a bug with Brightcove Support. If that is working, there isn't enough information here to debug further. You could try to compare what you are doing with the public sample apps available on Github:

https://github.com/BrightcoveOS/android-player-samples

These apps don't have multiple activities like your scenario, but they do handle the app going into the background and then being brought back to the foreground. Extending the BrightcovePlayer or BrightcovePlayerFragment enables the lifecycle handling. If you don't extend one of those classes, you have to write your own lifecycle handling, as if you were using the Android VideoView. For example, calling pause() in onPause() and calling stopPlayback() in onStop().