gpt4 book ai didi

ios - 我怎么能在像 Path 这样的 UIView 中嵌入视频?

转载 作者:可可西里 更新时间:2023-11-01 05:04:49 25 4
gpt4 key购买 nike

enter image description here

图片是从 Path App 截取的,你可以看到,在表格 View 中,有一个视频剪辑,当我点击播放按钮时,视频播放而没有切换到全屏。

视频似乎嵌入在表格 View 中?

如何做到这一点?你能举个例子吗?谢谢

最佳答案

取 self 的一个项目,只需根据您的需要进行调整即可:

    NSURL *movieUrl = [NSURL fileURLWithPath:moviePath];

MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:movieUrl];

player.view.frame = CGRectMake(0, 0, 690, 370);

// Here is where you set the control Style like fullscreen or embedded
player.controlStyle = MPMovieControlStyleDefault;
//player.controlStyle = MPMovieControlStyleEmbedded;
//player.controlStyle = MPMovieControlStyleDefault;
//player.controlStyle = MPMovieControlStyleFullscreen;


[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinished) name:MPMoviePlayerPlaybackDidFinishNotification object:player];

UIView *movieBox = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 600, 400)];
[movieBox setBackgroundColor:[UIColor blackColor]];

[movieBox addSubview:player.view];
[self.view addSubview:movieBox];
player.scalingMode = MPMovieScalingModeAspectFit;

player.contentURL = movieUrl;

[player play];

关于ios - 我怎么能在像 Path 这样的 UIView 中嵌入视频?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10910309/

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