【问题标题】:How to play a video like you tube player in iphone sdk?如何在 iphone sdk 中播放像你这样的电子管播放器的视频?
【发布时间】:2012-03-08 22:55:26
【问题描述】:

我是 ios 开发的新手,我正在做一个项目,我需要展示一些示例视频。

我想以流媒体格式显示视频(youtube 播放器)。

-(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];

    }
}

我试过这个,但没有用。请帮帮我...

【问题讨论】:

  • 欢迎来到 StackOverflow。提问时,请尽量做到描述性强。当您说您尝试过,但它“没有用”时,请解释为什么它没有用以及您尝试使其工作的原因等。

标签: iphone ios ipad ipod-touch


【解决方案1】:

试试这个

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

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

【讨论】:

    猜你喜欢
    • 2011-09-18
    • 2012-05-23
    • 1970-01-01
    • 1970-01-01
    • 2021-09-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多