开发者

How to detect MediaPlayer events of youtube from a service

I am developing an application to monitor and get statistics on youtube videos played on the phone.

I need to detect events that occur during playback of video, such as the time when the video begins or ends, or breaks that are produced by emptying the buffer.

For breaks, I solved the problem by analyzing the log to identify messages such as:

WARN/MediaPlayer(661): info/warning (701, 0) (PAUSE)

WARN/MediaPlayer(661): info/warning (702, 0) (RESUME)

The problem is that I have not found any message in the log to detect the end of the video. Ideally, you can use a OnCompletionListener to detect this event but I have not been able to get away. I think this type of listener will only work on MediaPlayer objects created in the application itself.

In this case, 开发者_JS百科the MediaPlayer has created another application (youtube) and I have no control over that object.

Does anyone know how to detect these events from an external service to the application that created the MediaPlayer? Can I use a BroadcastReceiver? Which?


Implement the OnInfoListener and create a method for it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜