Android 上视频播放结束时 JavaScript 结束事件

发布于 2024-09-05 11:42:30 字数 486 浏览 5 评论 0原文

我一直在尝试创建一个网页,该网页将在用户观看视频(或者中止播放)后重定向用户。我已经在 iPhone 上运行了,但无法真正弄清楚它在 Android 上如何运行。

在 Iphone 上我找到了两种方法来做到这一点。使用标签嵌入quicktime插件,然后使用javascript添加事件监听器来监听“qt_ending”事件。这显然不适用于 Android,因为没有 QuickTime 插件。

我尝试的第二件事是使用 html5 标签并监听“结束”事件,这同样适用于 iPhone,但令我惊讶的是不适用于 Android。在这种情况下,我在 Android 手机上播放视频,但在视频结束后没有发生重定向。所以我的猜测是,android 浏览器不完全支持视频标签,并且它不会触发该事件。

所以此时我真的不知道如何继续。我猜我可以做一些类似于 Quicktime 嵌入解决方案的事情,但使用 Android 上可用的插件。但我无法找到有关 Android 上可用的插件以及它们是否支持某种“结束”事件的任何信息。

I have been trying to create a web page that will redirect the user after he has watched a video (or if he aborted the playback). I've got this working on the iphone but can't really figure out how it works on the android.

On the Iphone i have found two ways of doing this. using the tag to embed the quicktime plugin and then adding a event listener with javascript to listen to the 'qt_ended' event. This does obviously not work on android because there is no quicktime plugin.

The second thing i tried was using the html5 -tag and listening to the 'ended' event, again this worked on the iphone but to my surprise not on android. In this case i got the video playing on the android phone but no redirect occurred after the video had reached the end. So my guess is that the android browser does not fully support the video-tag and that it does not fire the event.

So at this time i don't really know how to proceed. I'm guessing i could do something similar to the quicktime embed solution but using a plugin available on android. But i cant find any information on what plugins is available on the android and if they support some kind of 'ended'-event.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

西瑶 2024-09-12 11:42:30

Android 2.2 支持此功能,但 2.1 不支持。 Android 1.6 甚至不支持 Video 标签,所以这是不言而喻的。

我花了一些时间研究解决方法,但没有找到任何东西。

This is supported in Android 2.2, but not 2.1. Android 1.6 didn't even support the Video tag so that goes without saying.

I've spent some time looking into workarounds and haven't found anything.

胡渣熟男 2024-09-12 11:42:30

我对结束事件(Android 2.1)也有同样的问题,我已经找到了这个,但到目前为止还没有运气。
https://github.com/bcrescimanno/droidfix

我最终检测到 Android 2.1 或更低版本并显示用户可以激活该按钮,然后触发结束事件。

我使用 PHP 进行检测,如下所示,但您可以轻松地将其转换为 JavaScript。

if(strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false){

        $androidVersion = intval(substr($_SERVER['HTTP_USER_AGENT'], strpos($_SERVER['HTTP_USER_AGENT'], 'Android')+8, 3));

        if($androidVersion < 2.2) {
            echo 'android 2.1 or less';
        }
    }

I am having the same problem with the ended event (Android 2.1) I have found this but no luck so far.
https://github.com/bcrescimanno/droidfix

I ended up detecting for Android 2.1 or below and showing a button that the user could activate which then triggered the ended event.

I used PHP as follow for the detection, but you could easily convert it to JavaScript.

if(strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false){

        $androidVersion = intval(substr($_SERVER['HTTP_USER_AGENT'], strpos($_SERVER['HTTP_USER_AGENT'], 'Android')+8, 3));

        if($androidVersion < 2.2) {
            echo 'android 2.1 or less';
        }
    }
挽你眉间 2024-09-12 11:42:30

我在一些 Android 测试中发现此行为与视频文件相关。对于某些文件,它不起作用。使用重新编码的文件,它可以工作。

I found out in some Android testing that this behavior is video file dependent. With some file it do not work. With a re-encoded file, it works.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文