HTML5音频事件“进度”未触发 [英] HTML5 audio event 'progress' not firing

查看:201
本文介绍了HTML5音频事件“进度”未触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个/ v html5流式网络应用程序。这个问题预示着项目的音频部分,但是当我开始视频部分时,我确信我会遇到类似的情况。我的目标设备是iPad的safari浏览器(因此为什么我必须这样做html5)。播放效果很好,但是我有一个加载栏,需要反映轨道的载入量。遵循w3规范,我试图用jQuery实现这一点:

  var that = this; 
that.player = $('audio')[0];

$('that.player')。bind('progress',function(){
var buffer = that.player.buffered.end(0)
that。 updateLoadBuffer(buffer);
});

这没有工作。 'that.player.buffered'返回一个TimeRanges对象,而TimeRanges有一个方法'end(index)'返回由'index'指定的TimeRange的缓冲区结束的播放位置(以秒为单位),TimeRanges也有一个.length属性,告诉您对象封装了多少个TimeRanges。当我尝试登录该属性时,我发现TimeRanges.length = 0,意味着没有TimeRanges被传回。此外,当我将日志记录语句放入绑定函数中时,我发现进度事件从未被触发。对于loadedmetata和timeupdate事件,我有独立的功能,它们遵循类似的格式,并且按预期的方式启动。我尝试其他方法捕获事件无效:

  that.player.onprogress = function(e){
console.log('progressEvent hear');
};

that.player.addEventListener('progress',progressHandler,false)
函数progressHandler(e){
console.log('progressEvent hear');
};

这两个都没有触发我的控制台消息。我的音频标签声明如下:

 < audio style =width:0; height:0;>< ; /音频> 

我在这里做错什么?



更新:我正在使用wowzamediaserver来处理http流。我不知道这可能与它有什么关系。



另一个更新:我意识到我的音频标签没有源,那是因为我使用jquery动态设置它,如下所示:

$ ($ src','http://my.wowza.server:1935 / myStreamingApp / _definst_ / mp3)$($) :路径/要/我的/曲目/ audio.mp3 / playlist.m3u8' );

再次,我没有播放问题,所以这不应该对我的问题有任何影响,但我只是想让你们尽可能地清除图片。

解决方案

HTML5规范仍然是一个正在开发的草案,所以支持它的浏览器基本上符合一个尚未被定稿规格因此,我不会期望他们的HTML5功能可以完全实现...


I am building an a/v html5 streaming web app. This question pretains to the audio portion of the project, but i'm sure i will run into a similar situation when i get started on the video portion. My target device is the iPad's safari browser (hence why i have to do this html5). Playback works fine, but i have a loading bar which needs to reflect how much of the track has been loaded. Following the w3 spec, i tried to implement this the following way using jQuery:

var that = this;
that.player = $('audio')[0];

$('that.player').bind('progress',function(){
    var buffer = that.player.buffered.end(0)      
    that.updateLoadBuffer(buffer);
});

This did not work. 'that.player.buffered' returns a TimeRanges object, and TimeRanges have a method 'end(index)' which returns the playback position of end of the buffer in seconds for the TimeRange specified by 'index.' TimeRanges also have a .length property which tells you how many TimeRanges are encapsulated by the object. When i tried to log that property i found that TimeRanges.length = 0, meaning no TimeRanges are passed back. Also when i threw logging statements into the bound function, i found that the 'progress' event was never fired. I have separate functions for the 'loadedmetata' and 'timeupdate' events which follow a similar format, and those fire off as expected. I tried other methods for capturing events to no avail:

that.player.onprogress = function(e){
     console.log('progressEvent heard');
};

that.player.addEventListener('progress',progressHandler, false)
function progressHandler(e){
    console.log('progressEvent heard');
};

Neither of these triggered my console message. My audio tag declaration is as follows:

<audio style="width:0;height:0;"></audio>

what am i doing wrong here?

UPDATE: I am using wowzamediaserver to handle the http streaming. I dont know if that could have anything to do with it.

YET ANOTHER UPDATE: I realize i do not have a source in my audio tag, that is because i set it dynamically using jquery, as follows:

$('audio').attr('src','http://my.wowza.server:1935/myStreamingApp/_definst_/mp3:path/to/my/track/audio.mp3/playlist.m3u8');

again i am not having playback issues so this shouldn't have any bearing on my problem, but i just want to give you guys as clear of a picture as possible.

解决方案

The HTML5 specification is still a draft under development so browsers that support it are essentially conforming to a yet-to-be-finalized spec. As such I wouldn't expect their HTML5 features to be fully functional...

这篇关于HTML5音频事件“进度”未触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆