gpt4 book ai didi

iphone - 如何在 iphone sdk 中播放像 youtube 播放器这样的视频?

转载 作者:行者123 更新时间:2023-11-29 13:40:28 24 4
gpt4 key购买 nike

我是 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];

}
}

这个我试过了,没用。请帮助我...

最佳答案

试试这个

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

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

关于iphone - 如何在 iphone sdk 中播放像 youtube 播放器这样的视频?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9329984/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com