gpt4 book ai didi

objective-c - 我们可以将 mpmovieplayerviewcontroller 添加为 subview 吗?

转载 作者:行者123 更新时间:2023-12-01 16:02:46 25 4
gpt4 key购买 nike

我想在单击按钮时在同一 View 上播放视频。

NSURL *movieUrl = @"Some Url";
CGRect frame;
frame =CGRectMake(10,10,100,100);
MPMoviePlayerViewController *player = [[MPMoviePlayerViewController alloc] initWithContentURL:movieUrl];
[self.view addSubview:player.view];
player.view.frame = frame;
[player release];

当我运行它时,它显示一个黑色背景的框架,但不播放视频。我没有使用 YouTube 视频。

最佳答案

NSURL* videoURL = [NSURL URLWithString:url];
MPMoviePlayerController* mPlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
[mPlayer prepareToPlay];
[mPlayer play];

//For viewing partially.....
[mPlayer.view setFrame:CGRectMake(50, 200, (self.view.frame.size.width)-100 , 400)];
mPlayer.view.backgroundColor = [UIColor grayColor];
[self.view addSubview:mPlayer.view];

关于objective-c - 我们可以将 mpmovieplayerviewcontroller 添加为 subview 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6382054/

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