问题
I need to know if at an specific moment the MPMoviePlayerController is playing.
In iphone 3.0 it is not firing the MPMoviePlayerContentPreloadDidFinishNotification.
Does anyone knows any solution?
Thanks in advance!
回答1:
Same question (but no answer) here and several other reports can be found on other sites (e.g. here)
Not ideal, but it seems targeting 3.1 solves the problem.
A workaround maybe to set the MPMoviePlayerController
property scalingMode
to something other than the default MPMovieScalingModeAspectFit
( e.g. MPMovieScalingModeNone
and make sure your video is correct size) before calling play
and then hook the MPMoviePlayerScalingModeDidChangeNotification
event instead. it seems to get called (more than once!) as soon as the movie starts playing. Of course it will also be called if the user changes the scaling mode manually, so code for this. It's dirty but may help you?
回答2:
So thanks for the answer. I fix this so I will post the answer. The answer is that MPMoviePlayerContentPreloadDidFinishNotification is NOT FIRED if you invoke play() right after the initialization.
To have MPMoviePlayerContentPreloadDidFinishNotification which works ok you have to invoke the "play()" method of the MPMoviePlayerController when the MPMoviePlayerContentPreloadDidFinishNotification is fired ( I mean in the MPMoviePlayerContentPreloadDidFinishNotification method ). In this case it always works.
Tested on 3.0, 3.1 and 3.1.2
来源:https://stackoverflow.com/questions/2085311/how-to-know-that-mpmovieplayercontroller-is-playing-in-iphone-os-3-0