gpt4 book ai didi

iphone - IOS 上的 YouTube IFrame API 和 webkitExitFullScreen [重新访问]

转载 作者:可可西里 更新时间:2023-11-01 02:59:50 26 4
gpt4 key购买 nike

如何在移动设备 (iPhone) Safari (webkit) 上全屏访问 webkitExitFullScreen 功能。

在使用 IFrame API 的 iPhone 上,视频总是全屏播放,但之后我无法通过 JS 访问不同的功能,例如 webkitExitFullScreen

我看到这已经在 YouTube API Forum 中提交给论坛和团队。在这里:

https://groups.google.com/d/msg/youtube-api-gdata/fygn23jMbdE/pNE57RDl1gEJ

https://groups.google.com/forum/#!msg/youtube-api-gdata/7ioV74oFX84/U8zQ7-Yl9w4J

我想询问并跟进他们的问题,尤其是最后一个问题,因为已经是一年前的事了。但是这些小组现在已经关闭,并说我应该在这里提交。有谁知道这是否已在 the API 中的某处实现?已经,我可能已经错过了?或者如何联系团队,直接询问他们的进展或情况?

最佳答案

在你的viewdidload中写这个

 webView112 = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
webView112.backgroundColor = [UIColor redColor];
webView112.allowsInlineMediaPlayback = YES;
webView112.mediaPlaybackRequiresUserAction = NO;
webView112.delegate = self;
[self.view addSubview:webView112];

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"youtube" ofType:@"html"];
NSString *html = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];

[webView112 loadHTMLString:html baseURL:[NSURL URLWithString:@"any static url"]];

下面的方法将在您的视频完成后触发

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
if ( [[[request URL] scheme] isEqualToString:@"callback"] )
{

NSLog(@"get callback");
[webView112 removeFromSuperview];

return NO;
}

return YES;}

然后创建 .html 文件并将此代码粘贴到 .html 文件中

<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>

<script>
var elapsed = -1;
var isPlayerLoaded = false;
var tag = document.createElement('script');
tag.src = "http://www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

// 4. The API will call this function when the video player is ready.
function onPlayerReady(event) {
player.playVideo();
}

// function onPlayerError(event) {
// }
//
function onPlayerStateChange(event) {
var state = '';
switch(event.data) {
case YT.PlayerState.ENDED:
window.location = "callback:anything";
break;
case YT.PlayerState.PLAYING:
state = 'playing';
break;
case YT.PlayerState.PAUSED:
state = 'paused';
break;
case YT.PlayerState.BUFFERING:
state = 'buffering';
break;
case YT.PlayerState.CUED:
state = 'cued';
break;
default:
state = 'unstarted';
break;
}
jQuery('#log').append(state + "<br/>");
}

// 3. This function creates an <iframe> (and YouTube player)
// after the API code downloads.
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('player', {
height: '400',
width: '320',
videoId: 'y84oAUjA8ms',
playerVars: { 'autoplay': 0, 'modestbranding': 1, 'rel': 0, 'showinfo': 0, 'iv_load_policy': 3, 'controls': 1, 'playsinline':1 },
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
// 'onError': onPlayerError
}
});
}

</script>
</head>
<body style="padding:0;margin:0;background-color:#000000;">
<div id="log" style="background:#fff;height:0px;width:0%;margin-top:0px;"></div>
<div id="player" frameborder="0"></div>
</body>

关于iphone - IOS 上的 YouTube IFrame API 和 webkitExitFullScreen [重新访问],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17422654/

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