Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我使用 MPMoviePlayerController 在我的一个应用程序中播放电影文件。它工作正常。我有一个要求,我必须跟踪“用户播放电影的时间?”。为此,我正在使用 Omniture。我一直不知道从一开始就玩了多长时间谢谢
您只需要在电影开始时录制:
self.movieStartDate = [NSDate date];
当电影结束(或停止)时,获取从那时起已经过了多长时间
NSTimeInterval duration = [[NSDate date] timeIntervalSinceDate:self.movieStartDate];
duration然后将包含自电影开始以来的时间量,以秒为单位。
duration
但请记住,电影可能会因为应用程序进入后台/变为非活动状态而停止,因此您必须听取这些通知以及来自电影播放器的通知 :)