Search code examples
iphoneiosobjective-cmpmovieplayercontroller

Difference between prepareToPlay and Play in MPMoviePlayerController


Please let me know the difference between prepareToPlay & play Methods in MPMoviePlayerController at the time of Video Play.

The syntax are:

[moviePlayer prepareToPlay];

And

[moviePlayer play];

Solution

  • As Method say that

    prepareToPlay - is not starting to play but it is under process for play whatever (video/audio).

    play - says that it is do string to play whatever (video/audio).

    as Document say:

    play

    Initiates playback of the current item. (required)

    - (void)play  
    

    Discussion
    If playback was previously paused, this method resumes playback where it left off; otherwise, this method plays the first available item, from the beginning.

    If a movie player is not prepared for playback when you call this method, this method first prepares the movie player and then starts playback. To minimize playback delay, call the prepareToPlay method before you call this method.

    To be notified when a movie player is ready to play, register for the MPMoviePlayerLoadStateDidChangeNotification notification. You can then check load state by accessing the movie player’s loadState property.

    Availability Available in iOS 3.2 and later. Declared In MPMediaPlayback.h

    prepareToPlay

    Prepares a movie player for playback. (required)

    - (void)prepareToPlay
    

    Discussion
    If a movie player is not already prepared to play when you call the play method, that method automatically calls this method. However, to minimize playback delay, call this method before you call play.

    Calling this method may interrupt the movie player’s audio session. For information on interruptions and how to resond to them, see Audio Session Programming Guide.

    Availability Available in iOS 3.2 and later.

    Declared In MPMediaPlayback.h

    For More Information read This Official Documentation.