【发布时间】:2013-04-05 02:50:05
【问题描述】:
我想在使用Durandal 框架构建的单页应用程序上使用 jwplayer。这个想法是创建一个不受应用程序导航影响的持久音频播放器。但是我一直无法在 Durandal 中加载 jwplayer。
我已经成功loaded jwplayer on a simple html file using Require.js。但是这种方法似乎不适用于 Durandal(也使用 Require.js)。
这是我在 shell.js 上的代码:
define(['jwplayer/jwplayer','durandal/plugins/router','durandal/app'], function (jwplayer,router,app) {
jwplayer.api('player').setup({
width: '320',
height: '40',
sources: [{
file: "rtmp://127.0.0.1:1935/vod/mp3:sample_1.mp3"
},{
file: "http://127.0.0.1:1935/vod/sample_1.mp3/playlist.m3u8"
}]
});
return {
router: router,
activate: function () {
...
}
};
});
在 shell.html 我有这个代码:<div id="player">loading player...</div>
这是我收到的错误消息:
Uncaught TypeError: Cannot read property 'id' of null jwplayer.js:37
似乎player 元素在 Durandal 模块中无法识别。是什么导致了这个问题?如何在 Durandal 模块中添加 jwplayer?
【问题讨论】:
标签: requirejs jwplayer durandal