iPad Safari 上 HTML5 视频中的事件侦听器无法正常工作?

发布于 2024-09-05 13:41:12 字数 1901 浏览 5 评论 0原文

我在 中得到了这个:

<script>
      function log(event){
     var Url = "./log.php?session=<?php echo session_id(); ?>&event=" + event;

        xmlHttp = new XMLHttpRequest(); 
        xmlHttp.open( "GET", Url, true );
        xmlHttp.send( null );

    }
</script> 

中得到了这个:

<video id="video" src="./video/LarryVideo.mp4" 
  controls="controls" 
  poster="./img/video_poster.jpg"
  onabort="log('onabort');"
  oncanplay="log('oncanplay');"
  oncanplaythrough="log('oncanplaythrough');"
  ondurationchange="log('ondurationchange');"
  onemptied="log('onemptied');"
  onended="log('onended');"
  onerror="log('onerror');"
  onloadeddata="log('onloadeddata');"
  onloadedmetadata="log('onloadedmetadata');"
  onloadstart="log('onloadstart');"
  onpause="log('onpause');"
  onplay="log('onplay');"
  onplaying="log('onplaying');"
  onprogress="log('onprogress');"
  onratechange="log('onratechange');"
  onreadystatechange="log('onreadystatechange');"
  onseeked="log('onseeked');"
  onseeking="log('onseeking');"
  onstalled="log('onstalled');"
  onsuspend="log('onsuspend');"
  ontimeupdate="log('ontimeupdate');"
  onvolumechange="log('onvolumechange');"
  onwaiting="log('onwaiting');">
    <script>
        QT_WriteOBJECT('./video/LarryVideo.mp4',
            '380px', '285px',           // width & height
            '',                         // required version of the ActiveX control, we're OK with the default value
            'scale', 'tofit',           // scale to fit element size exactly so resizing works
            'emb#id', 'video_embed',    // ID for embed tag only
            'obj#id', 'video_obj');     // ID for object tag only
    </script> 
</video>

我普通的 Safari 按预期创建了很好的日志文件条目。然而 iPad 上的 Mobile Safari 根本不执行任何操作。

这可能有什么问题吗?

I've got this in the <head>:

<script>
      function log(event){
     var Url = "./log.php?session=<?php echo session_id(); ?>&event=" + event;

        xmlHttp = new XMLHttpRequest(); 
        xmlHttp.open( "GET", Url, true );
        xmlHttp.send( null );

    }
</script> 

And this in the <body>:

<video id="video" src="./video/LarryVideo.mp4" 
  controls="controls" 
  poster="./img/video_poster.jpg"
  onabort="log('onabort');"
  oncanplay="log('oncanplay');"
  oncanplaythrough="log('oncanplaythrough');"
  ondurationchange="log('ondurationchange');"
  onemptied="log('onemptied');"
  onended="log('onended');"
  onerror="log('onerror');"
  onloadeddata="log('onloadeddata');"
  onloadedmetadata="log('onloadedmetadata');"
  onloadstart="log('onloadstart');"
  onpause="log('onpause');"
  onplay="log('onplay');"
  onplaying="log('onplaying');"
  onprogress="log('onprogress');"
  onratechange="log('onratechange');"
  onreadystatechange="log('onreadystatechange');"
  onseeked="log('onseeked');"
  onseeking="log('onseeking');"
  onstalled="log('onstalled');"
  onsuspend="log('onsuspend');"
  ontimeupdate="log('ontimeupdate');"
  onvolumechange="log('onvolumechange');"
  onwaiting="log('onwaiting');">
    <script>
        QT_WriteOBJECT('./video/LarryVideo.mp4',
            '380px', '285px',           // width & height
            '',                         // required version of the ActiveX control, we're OK with the default value
            'scale', 'tofit',           // scale to fit element size exactly so resizing works
            'emb#id', 'video_embed',    // ID for embed tag only
            'obj#id', 'video_obj');     // ID for object tag only
    </script> 
</video>

My normal Safari creates nice log-file entries as expected. Mobile Safari from iPad however doesn't do anything at all.

What could be wrong with this?

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

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

发布评论

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

评论(1

不弃不离 2024-09-12 13:41:12

我也无法在 ipad 上获取就绪状态,但您可以获得其他事件,或多或少让您推断就绪状态。

var audio = new Audio("someSource.mp3");
    audio.play(); 
 /* you may need to use .load() depending on how the event was initiated */
    audio.addEventListener("canplay", handleCanPlay, false);
    audio.addEventListener("durationchange", handleDurationChange, false);

但我们要明确的是,问题是苹果公司几乎告诉全世界他们使用互联网的方式是错误的。诚然,每个人都讨厌加载后就开始播放音乐的网站,但苹果公司却发疯了,杀死了任何/所有未由用户手势明确启动的音频/视频缓冲,因为苹果显然认为他们的用户不能如果某个网站打扰了他们,请点击“返回”;粉丝们也同意。如果我们敢于尝试和管理任何类型的声音效果,这基本上会让我们其他人破解我们的应用程序。我知道这不是咆哮的地方,但是在 iPad 上用 HTML5 构建任何有趣/交互式体验的软件都是一次又一次的捂脸——如果页面“太多”,5mb 缓存限制只会导致浏览器崩溃许多(根据 Apple 的说法)图像,或者难以预加载任何类型的媒体来增强 UI。说实话,除了 WordPress 博客和 RSS 阅读器之外,移动 Safari 的 HTML5 实现几乎毫无价值。因此,HTML5“一次构建,随处播放”价值主张的梦想已经破灭,我们又回到了开发本机应用程序。至少这给了我们良好的工作保障! /咆哮

I have not been able to get a hold of readystate on an ipad either, but you can get other events that more-or-less let you infer the readystate.

var audio = new Audio("someSource.mp3");
    audio.play(); 
 /* you may need to use .load() depending on how the event was initiated */
    audio.addEventListener("canplay", handleCanPlay, false);
    audio.addEventListener("durationchange", handleDurationChange, false);

But let's be clear, the problem is Apple pretty much telling the whole world they're using the internet wrong. Granted, everyone hates sites that start playing music the second they load, but then Apple goes nuts and kills ANY/ALL buffering of audio/video that isn't explicitly initiated by a user gesture because Apple, apparently, thinks their users can't hit "back" if a site bothers them; fanboys agree too. This basically leaves the rest of us to hack up our applications if we dare try and manage any kind of sound effects. I know this isn't the place to rant, but building ANY soft of interesting/interactive experience in HTML5 on the iPad is one facepalm after another -- be it the 5mb cache limit that simply crashes the browser if a page has "too" many (according to Apple) images, or the difficulty to preload any sort of media to enhance UI. Seriously, outside of Wordpress blogs and RSS readers, mobile Safari's implementation of HTML5 is pretty worthless. And so the dream of HTML5 "build once, play anywhere" value proposition is dead and we go back to developing native apps. At least this gives us good job security! /rant

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