简体   繁体   English

MPMovie播放器如何获得播放时间?

[英]MPMovie player how to get the amount of time played?

I was trying to go through the iPhone's sample code for mediaplayer. 我试图浏览iPhone的Mediaplayer示例代码。

I want to be able to capture the amount of time the media player has played the video. 我希望能够捕获媒体播放器播放视频的时间。 The duration at which the media player has stopped. 媒体播放器停止的持续时间。 Is there a method or property that will tell me the duration of play of the media?? 有没有一种方法或属性可以告诉我媒体播放的持续时间?

Yes, You can use the property "duration" defined by MPMediaPlayerController. 是的,您可以使用MPMediaPlayerController定义的属性“ duration”。 Plese try it out and check the output. 请尝试一下并检查输出。 U can refer the here duration property 你可以参考这里的duration属性

Unfortunately the current API for MPMoviePlayerController allows basically no control. 不幸的是,当前用于MPMoviePlayerController的API基本上不允许控制。 You can tell it to play and stop... otherwise where's a delegate method so you can be notified when the movie finishes playing and that's it, there's no additional controls. 您可以告诉它播放和停止...否则,在哪里有一个委托方法,这样在电影结束播放时就可以通知您,仅此而已,就没有其他控件。 (a real bummer) (真是可惜)

However, while we cant discuss the new 3.2 SDK yet, I'll give you a tip and say go look at the documentation of MPMoviePlayer in 3.2 and I think you'll be happy. 但是,尽管我们还不能讨论新的3.2 SDK,但我会给您一个提示,说看看3.2中的MPMoviePlayer文档,我认为您会很高兴的。

http://developer.apple.com/iphone/prerelease/library/documentation/MediaPlayer/Reference/MPMoviePlayerController_Class/MPMoviePlayerController/MPMoviePlayerController.html http://developer.apple.com/iphone/prerelease/library/documentation/MediaPlayer/Reference/MPMoviePlayerController_Class/MPMoviePlayerController/MPMoviePlayerController.html

moviePlayer.currentPlaybackTime

不可能在上面执行KVO,但是您可以像我一样创建一个ScheduledTimer,它每秒更新一次,以检查当前播放时间是什么,并相应地更新图形:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM