Android中的VideoView [英] VideoView in Android

查看:49
本文介绍了Android中的VideoView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Android中使用VideoView来显示流式视频. 在播放视频时,如果用户收到&断开呼叫,视频从头开始播放,而不是从断开呼叫后,视频应从接到呼叫的同一位置开始播放的行为.

I am using VideoView in Android for displaying streaming videos. While playing the videos if a user receives & disconnects the call ,the video starts playing from beginning instead of the behavior which should be that after the call disconnection ,the video should start playing from the same place when the call was received.

如果您已经实施了建议/示例代码,请提供它们.

Kindly provide your suggestions/sample code if you have already implemented the same.

推荐答案

我还没有尝试过,但这是我要开始的地方:

I have not tried this, but this is where I would start:

步骤1:在onStop()中,调用VideoView上的getCurrentPosition()并保存该值.

Step #1: In onStop(), call getCurrentPosition() on the VideoView and save the value.

步骤2:在onStart()中,调用VideoView上的getCurrentPosition(),并将其与步骤1中的值进行比较.如果它们不同(例如getCurrentPosition()现在为0),请调用seekTo(),并提供步骤1中的值.

Step #2: In onStart(), call getCurrentPosition() on the VideoView and compare it to the value from Step #1. If they differ (e.g., getCurrentPosition() is now 0), call seekTo(), supplying the value from Step #1.

步骤3:在onSaveInstanceState()中,调用VideoView上的getCurrentPosition()并将值存储在提供的Bundle中.

Step #3: In onSaveInstanceState(), call getCurrentPosition() on the VideoView and store the value in the supplied Bundle.

步骤#4:在onRestoreInstanceState()中,从提供的Bundle中获得步骤#3的值,并将其放入步骤#1和步骤#2使用的数据成员中.

Step #4: In onRestoreInstanceState(), obtain the value from Step #3 from the supplied Bundle and put it in the data member used by Step #1 and Step #2.

这应该涵盖您在通话过程中可能发生的相关情况.

This should cover you for the relevant scenarios that might occur while the phone call is going on.

这篇关于Android中的VideoView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆