writing an iPhone application with embedded video

前端 未结 2 1051
萌比男神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: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]; 
    }
    

提交回复
热议问题