How do you get an iphone MPMoviePlayer video's total time?

我怕爱的太早我们不能终老 提交于 2019-12-05 01:41:55

问题


I just want to figure out how to get a video's total time in seconds. Is there video metadata that loads or something?


回答1:


MPMoviePlayerController has a property duration (iOS 3.2+):

The duration of the movie, measured in seconds. (read-only)

@property (nonatomic, readonly) NSTimeInterval duration

If the duration of the movie is not known, the value in this property is 0.0. If the duration is subsequently determined, this property is updated and a MPMovieDurationAvailableNotification notification is posted.




回答2:


Get the length of the video in bytes using NSdata. After that calculate how many bytes for playing one second of video. And you can calculate the length of the video:)




回答3:


Why dont you simply use the (NSTimeInterval)duration property to get the videos length??



来源:https://stackoverflow.com/questions/1214958/how-do-you-get-an-iphone-mpmovieplayer-videos-total-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!