Unable to pause/forward/backward video using media

2019-08-02 17:35发布

Iam unable to pause / forward / backward the video using MediaController and it is happening only in the LG devices. Below is the code which am using and it is working in the rest of all the devices :

    VideoView video=(VideoView)findViewById(R.id.video);
    MediaController mediaController = new MediaController(this);
    mediaController.setAnchorView(video);
    video.setMediaController(mediaController);
    video.setVideoURI(uri);
    video.start();

Please help me on this.

1条回答
Animai°情兽
2楼-- · 2019-08-02 18:11

Finally I found a solution...

In some LG devices, by defaultly controls are disabled in VideoView.

So we have to explicitly enable them by Overriding the below functions in VideoView:

@Override
public boolean canSeekForward() {
    return true;
}

@Override
public boolean canSeekBackward() {
    return true;
}

@Override
public boolean canPause() {
    return true;
}
查看更多
登录 后发表回答