Karthik KR
Karthik KR

Reputation: 51

How to play a video like you tube player in iphone sdk?

I am newbie for ios development, I am working on a project ,where i need to show some sample videos.

i Would like to show the video in streaming format(youtube player) .

-(void) playVideoOfURL:(NSString*)videoPath
{
    NSString *url = [NSString stringWithFormat:@"%@%@",TipsService,videoPath];

    moviePlayer = [[ MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]];
    if (moviePlayer)
    {

        moviePlayer.view.frame = CGRectMake(0, 0, 320, 460);
        moviePlayer.scalingMode = MPMovieScalingModeAspectFill; 
        moviePlayer.controlStyle = MPMovieControlStyleDefault;
        moviePlayer.movieSourceType = MPMovieSourceTypeFile;
        moviePlayer.useApplicationAudioSession = YES;
        //Register for the playback finished notification.
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieFinishedCallback:) name:MPMoviePlayerDidExitFullscreenNotification object:moviePlayer];

        //setup device rotation notification observer
        [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];   
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(didRotate:)
                                                     name:UIDeviceOrientationDidChangeNotification 
                                                   object:nil]; 

        UIViewController *player = [[UIViewController alloc] init];
        player.view = moviePlayer.view;

        [self.navigationController pushViewController:player animated:YES];
        [moviePlayer play];
        [moviePlayer setFullscreen:TRUE];

    }
}

I tried this one, but no use. Please help me...

Upvotes: 1

Views: 1051

Answers (1)

rakeshNS
rakeshNS

Reputation: 4257

Try this

 [moviePlayer play];
 [moviePlayer setFullscreen:TRUE];
 UIViewController *player = [[UIViewController alloc] init];
 player.view = moviePlayer.view;

 [self.navigationController pushViewController:player animated:YES];

Upvotes: 1

Related Questions