writing an iPhone application with embedded video

前端 未结 2 1050
萌比男神i
萌比男神i 2021-02-06 15:41

I am researching video streaming for an iPhone application that I may have to write in the near future. The application does a whole lot other than stream video, but video aspec

相关标签:
2条回答
  • 2021-02-06 16:07

    I am looking at this issue as well. I would like to embed a video in an iPad app, something like how the Associated Press iPad application handles videos.

    Apparently you can do this type of embedded video in OS 3.2 and later. Apple's documentation for MPMoviePlayerController describes how this can be done:

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

    0 讨论(0)
  • 2021-02-06 16:10

    Apple provide good documentation on the media framework i ntheir docs.

    Search for MPMoviePlayerController. The following sample code plays a movie from a URL. (disclaimer, this code lifted from Apple).

    -(void)playMovieAtURL:(NSURL*)theURL 
    
    {
        MPMoviePlayerController* theMovie=[[MPMoviePlayerController alloc] initWithContentURL:theURL]; 
        theMovie.scalingMode=MPMovieScalingModeAspectFill; 
        theMovie.userCanShowTransportControls=NO;
    
        // Register for the playback finished notification. 
    
        [[NSNotificationCenter defaultCenter] addObserver:self 
                                                selector:@selector(myMovieFinishedCallback:) 
                                                    name:MPMoviePlayerPlaybackDidFinishNotification 
                                                  object:theMovie]; 
    
        // Movie playback is asynchronous, so this method returns immediately. 
        [theMovie play]; 
    } 
    
    // When the movie is done,release the controller. 
    -(void)myMovieFinishedCallback:(NSNotification*)aNotification 
    {
        MPMoviePlayerController* theMovie=[aNotification object]; 
        [[NSNotificationCenter defaultCenter] removeObserver:self 
                                                        name:MPMoviePlayerPlaybackDidFinishNotification 
                                                      object:theMovie]; 
    
        // Release the movie instance created in playMovieAtURL
        [theMovie release]; 
    }
    
    0 讨论(0)
提交回复
热议问题