2011-05-02 105 views
3

我创建的音频播放器,MediaElement.js,像这样:MediaElement.js - 让调试信息

//button has been clicked, create new audio player and play 
var audioElement = $('<audio>', { 
    id : 'audioPlayer' + index, 
    src : '/streamFriendFile', 
    loop : 'loop', 
    preload : 'none' 
})[0]; 
$(row).append(audioElement); 
new MediaElement(audioElement, { 
    plugins : ['flash', 'silverlight'], 
    pluginPath : 'http://localhost:3000/mediaelement/', 
    flashName : 'flashmediaelement.swf', 
    silverlightName : 'silverlightmediaelement.xap', 
    pluginWidth : 0, 
    pluginHeight : 0, 
    audioWidth: 0, 
    audioHeight : 0, 
    startVolume: 0.8, 
    //loop: true, 
    //enableAutosize: false, 
    //features : [], 
    //timerRate : 250, 
    success : function(mediaElement, domObj) { 
     console.log('mediaElement success!'); 
     mediaElement.play(); 
    }, 
    error : function(mediaElement) { 
     console.log('medialement problem is detected: %o', mediaElement); 
    } 
}); 

错误回调立即调用,但它仅包含媒体元素作为参数。这并不能告诉我什么是错的。

如何获取实际的错误消息,以便我可以调试此问题?

请注意,我只使用MediaElement核心API,因此不是真正的播放器(所以我只包含mediaelement.js)。

回答

3

在您的MediaElement选项(以及flashName,silverlightName等)中,添加enablePluginDebug:true,它应该在屏幕上显示调试错误。从代码示例中的API reference开始。

除此之外,我不认为他们对该错误对象有任何详细的错误处理,但从查看github repo看起来它似乎是底部提到的“待办事项”功能(很可能是2.2功能) 。

看起来你可能必须找出你自己的错误处理暂时。