gpt4 book ai didi

iphone - iDevice onclick 不使用当前代码播放视频

转载 作者:行者123 更新时间:2023-12-03 20:06:05 28 4
gpt4 key购买 nike

我的最终目标是在 iDevices 上查看我的网站,点击图像链接后,全屏播放视频,视频结束后重定向到另一个网页。我对任何能够实现我的目标的解决方案持开放态度,即使这意味着废弃我已有的代码。

这是我迄今为止最好的尝试:这是My current testing site

我正在关注this stackoverflow post

我对笔记本电脑上的结果感到满意[编辑适用于 Chrome,但不适用于 FF 16.0.1 唉,我不知道了),但我目前无法单击图像来播放我的 iDevices(ipad1 和 iphone4)上的视频。我花了几个小时试图通过研究、试验和错误来实现这一目标,但没有成功。

这是我正在使用的代码:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width; initial-scale=1.0" />
<meta name="description" content="" />
<title>test</title>

<script type="text/javascript">

function videoEnd() {
var video = document.getElementById("video");
video.webkitExitFullScreen();
document.location = "http://www.atxcloud.com/wp-content/uploads/Panos/beerdiaries/jk5%20all/build.html";
}

function playVideo() {
var video = document.getElementById("video");
video.addEventListener('ended', videoEnd, true);
video.webkitEnterFullScreen();
video.load();
video.play();
}

</script>
</head>
<body>
<video id="video" poster="http://www.atxcloud.com/wp-content/uploads/Panos/beerdiaries/RnD/image.png" onclick="playVideo();">
<source src="http://www.atxcloud.com/wp-content/uploads/Panos/beerdiaries/RnD/video.mp4" type="video/mp4" />
</video>
</body>
</html>

最佳答案

如果浏览器不支持全屏 API (http://caniuse.com/#feat=fullscreen),则可能会在您的 playVideo 函数中引发错误。尝试这个修改:

function videoEnd() {
var video = document.getElementById("video");
if(video.webkitExitFullScreen) video.webkitExitFullScreen();
document.location = "http://www.atxcloud.com/wp-content/uploads/Panos/beerdiaries/jk5%20all/build.html";
}

function playVideo() {
var video = document.getElementById("video");
if(video.webkitEnterFullScreen) video.webkitEnterFullScreen();
video.load();
video.play();
}

<video id="video" poster="http://www.atxcloud.com/wp-content/uploads/Panos/beerdiaries/RnD/image.png" onclick="playVideo();" onended="videoEnd();">
<source src="http://www.atxcloud.com/wp-content/uploads/Panos/beerdiaries/RnD/video.mp4" type="video/mp4" />

关于iphone - iDevice onclick 不使用当前代码播放视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12994138/

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