【发布时间】: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