Search code examples
iosvideo-streamingmpmovieplayercontroller

MPMoviePlayer Controller blackscreen when Status bar hides


I am trying to get a videostream to work. My Code works super, it starts playing (fetches the Video From an url provided by Apple Support Sites - the player plays the first four seconds of the Video and then when this little status bar thing wants to automatically hide the player goes blackscreen (with Status bar I mean the indicator of Time, with the fullscreen Button etc.). I cant Post sourcecode right now because I am writing with my iPhone, so I will do that later... Hope That my description helps you to understand and maybe you can help me.


Solution

  • In my .h File:

    MPMoviePlayerController *mp;
    

    In my .m File:

            NSURL *mediaURL = [NSURL URLWithString:@"http://km.support.apple.com/library/APPLE/APPLECARE_ALLGEOS/HT1211/sample_iTunes.mov"];
            mp = [[MPMoviePlayerController alloc] init];
            [mp setShouldAutoplay:YES];
            [mp setMovieSourceType:MPMovieSourceTypeStreaming];
            [mp setContentURL:mediaURL];
            [mp setControlStyle:MPMovieControlStyleEmbedded];
            [mp setFullscreen:NO];
            [mp setScalingMode:MPMovieScalingModeNone];
            [mp prepareToPlay];
            mp.view.frame=CGRectMake(0, 0, 320, 220);
            [self.view addSubview:mp.view];
    

    this is working fine :)