2018-07-05 13:50:52 +00:00
|
|
|
define(function(require, exports) {
|
|
|
|
var playStart = function(vedioInfo){
|
|
|
|
var $target = createDialog(vedioInfo.name);
|
|
|
|
var typeArr = {
|
|
|
|
'f4v' : 'flv',
|
|
|
|
'f4a' : 'flv',
|
|
|
|
'm4a' : 'mp3',
|
|
|
|
'aac' : 'mp3',
|
|
|
|
'ogg' : 'oga',
|
|
|
|
};
|
|
|
|
var type = typeArr[vedioInfo.ext] || vedioInfo.ext;
|
2018-08-22 14:55:14 +00:00
|
|
|
var playerOption = {
|
2018-07-05 13:50:52 +00:00
|
|
|
container:$target.get(0),
|
|
|
|
preload: 'none',
|
|
|
|
theme:'#f60',
|
|
|
|
loop: false,
|
|
|
|
autoplay:true,
|
|
|
|
lang: 'zh-cn',
|
|
|
|
//flv仅支持 H.264+AAC编码 https://github.com/Bilibili/flv.js/issues/47
|
|
|
|
video: {
|
|
|
|
url:vedioInfo.url,
|
|
|
|
type:type
|
2018-08-22 14:55:14 +00:00
|
|
|
},
|
2018-07-05 13:50:52 +00:00
|
|
|
danmaku: {
|
|
|
|
id:md5(vedioInfo.url),
|
|
|
|
api:'https://api.prprpr.me/dplayer/'
|
|
|
|
},
|
|
|
|
contextmenu: [
|
|
|
|
{
|
|
|
|
text: 'kodcloud官网',
|
|
|
|
link: 'https://kodcloud.com/'
|
|
|
|
}
|
|
|
|
]
|
2018-08-22 14:55:14 +00:00
|
|
|
};
|
|
|
|
if(window.DplayerSubtitle){
|
|
|
|
// 默认加载同名文件字幕;暂时只支持vtt格式 http://dplayer.js.org/#/home?id=options
|
|
|
|
playerOption.subtitle = {
|
|
|
|
url:core.path2url(vedioInfo.path+'.vtt')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
new DPlayer(playerOption);
|
2018-07-05 13:50:52 +00:00
|
|
|
}
|
|
|
|
var createDialog = function(title,ext){
|
|
|
|
var size = {width:'70%',height:'60%'};
|
|
|
|
if(ext == 'mp3'){
|
|
|
|
size = {width:'320px',height:'420px'};
|
|
|
|
}
|
|
|
|
var dialog = $.dialog({
|
|
|
|
//id:'movie-dialog',
|
|
|
|
simple:true,
|
|
|
|
ico:core.icon('mp4'),
|
|
|
|
title:title,
|
|
|
|
width:size.width,
|
|
|
|
height:size.height,
|
|
|
|
content:'<div class="Dplayer"></div>',
|
|
|
|
resize:true,
|
|
|
|
padding:0,
|
|
|
|
fixed:true,
|
|
|
|
close:function(){
|
|
|
|
}
|
|
|
|
});
|
|
|
|
dialog.DOM.wrap.addClass('dplayer-dialog');
|
|
|
|
return dialog.DOM.wrap.find(".Dplayer");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var playReady = function(appStatic,vedioInfo){
|
|
|
|
require.async([
|
|
|
|
appStatic+'DPlayer/lib/flv.min.js',
|
|
|
|
appStatic+'DPlayer/lib/hls.min.js',
|
|
|
|
appStatic+'DPlayer/lib/dash.all.min.js',
|
|
|
|
appStatic+'DPlayer/DPlayer.min.css',
|
|
|
|
appStatic+'DPlayer/DPlayer.min.js',
|
|
|
|
],function(a){
|
|
|
|
playStart(vedioInfo);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
play:playReady
|
|
|
|
};
|
|
|
|
});
|