Search code examples
iphoneiphone-sdk-3.0video-streamingmedia-playerlive-video

iPhone Live Video Stream Media Player


I'm hoping to make an app that streams live video that has a view placed on top with labels and a button on it.

From my research and testing of the http video streaming feature (available since iPhone 3.0 OS), it seems that you create a webview that points to the index html that contains the converted video stream, and this displays as a quicktime video in the app. This means that I don't have control over the Media Player that is opened. Does anyone know how you can control this?

I know that the Apple's MoviePlayer sample code shows you how to place views on top of a MediaPlayer video, but how can this be done with a http live stream?

Thanks in advance.


Solution

  • Im now just having a problem displaying a view/label/button on top of the movieplayer video. In Apple's MoviePlayer sample project, you can add a view on top of the video with this code:

    MoviePlayerAppDelegate *appDelegate = (MoviePlayerAppDelegate *)[[UIApplication sharedApplication] delegate];     
    
    // initialize a new MPMoviePlayerController object with the specified URL, and play the movie
    [appDelegate initAndPlayMovie:[self localMovieURL]];
    
    NSArray *windows = [[UIApplication sharedApplication] windows];
    
    if ([windows count] > 1) {
         // Locate the movie player window
         UIWindow *moviePlayerWindow = [[UIApplication sharedApplication] keyWindow];
    
         // Add our overlay view to the movie player's subviews so it is displayed above it.
         [moviePlayerWindow addSubview:self.overlayView];
    }
    

    The overlayview is a view that contains the requested label and button. However, when I apply the same code to a movie url containing the .m3u8 file it doesn't display the overlay view e.g.http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8

    NSURL *newMovieURL = [NSURL URLWithString:@"http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8">];
    
    if (movieURL) {
         NSLog(@"movieURL");
    
         if ([movieURL scheme])     // sanity check on the URL
         { NSLog(@"[movieURL scheme]");
              [appDelegate initAndPlayMovie:newMovieURL];
    
              NSArray *windows = [[UIApplication sharedApplication] windows];
              NSLog(@"windows count:%d", [windows count]);
    
           if ([windows count] > 1) {
              UIWindow *moviePlayerWindow = [[UIApplication sharedApplication] keyWindow];
              [moviePlayerWindow addSubview:self.overlayView];
              }
         }
         else NSLog(@"![movieURL scheme]"); } else
         NSLog(@"!movieURL");
    

    The number of windows returned is just 1, as opposed to 2 in the previous example, even though the movie plays. When I check the url to see if it was ok, the movieURL returns null, but it still plays the streamed content. I tried removing the check for window count being greater than 1 but it still didnt display the overlay view.

    Does anybody know a way around this? Thanks