Play file in browser or with external helper application
This commit is contained in:
parent
9fa3a463ce
commit
e8c7b2f4fc
|
@ -781,12 +781,14 @@ $('img.doopt').contextMenu(
|
||||||
// Disable items which are not yet implemented.
|
// Disable items which are not yet implemented.
|
||||||
$('#optmenu').disableContextMenuItems('#title');
|
$('#optmenu').disableContextMenuItems('#title');
|
||||||
|
|
||||||
var $buttons = {
|
var $buttons = [
|
||||||
"Close" : function() {$(this).dialog('close');}
|
{ id: 'close',
|
||||||
};
|
text: 'Close',
|
||||||
var $buttonsp = $.extend(
|
click: function() {$(this).dialog('close');}},
|
||||||
{"Play" : function() { doplay(); }},
|
{ id: 'play',
|
||||||
$buttons);
|
text: 'Play',
|
||||||
|
click: function() { doplay(this); };
|
||||||
|
];
|
||||||
|
|
||||||
// Create reusable dialogue.
|
// Create reusable dialogue.
|
||||||
var $dialog = $('#dialogue').dialog({
|
var $dialog = $('#dialogue').dialog({
|
||||||
|
@ -800,16 +802,47 @@ var $dialog = $('#dialogue').dialog({
|
||||||
'<img src="/img/spin.gif">Retrieving data...'); }
|
'<img src="/img/spin.gif">Retrieving data...'); }
|
||||||
});
|
});
|
||||||
|
|
||||||
function doplay()
|
function doplay(it)
|
||||||
{
|
{
|
||||||
var file = $dialog.attr('file');
|
var file = $dialog.attr('file');
|
||||||
var type = $dialog.attr('type');
|
var type = $dialog.attr('type');
|
||||||
|
|
||||||
disableall();
|
var duration = 0;
|
||||||
|
var fmts = "";
|
||||||
|
var vc = ""
|
||||||
|
var ff = $('#ffmpeg')[0];
|
||||||
|
|
||||||
|
if (ff) {
|
||||||
|
/* extract duration, container and video codec from ffmpeg output */
|
||||||
|
ff = ff.innerHTML;
|
||||||
|
var match = /Duration:\s+([0-9.:]+),/.exec(ff);
|
||||||
|
if (match && match[1])
|
||||||
|
duration = (new Date('1970-01-01T' + match[1] + 'Z')).getTime()/1000;
|
||||||
|
match = /Input #0,\s+([-A-Za-z0-9_,]+),\s/.exec(ff);
|
||||||
|
if (match && match[1]) fmts = match[1];
|
||||||
|
match = /Stream #.+\sVideo:\s+([-A-Za-z0-9_]+)\s/.exec(ff);
|
||||||
|
if (match && match[1]) vc = match[1];
|
||||||
|
}
|
||||||
|
|
||||||
window.location = '/play/play.jim?' +
|
fmts = /mp4|webm/.exec(fmts);
|
||||||
'dir=' + encodeURIComponent(dir) +
|
if (fmts && fmts[0])
|
||||||
'&file=' + encodeURIComponent(file);
|
vc = /h264|av1|vp9/.exec(vc);
|
||||||
|
else
|
||||||
|
vc = null;
|
||||||
|
|
||||||
|
if (vc && vc[0]) {
|
||||||
|
/* base on page address to handle client on external network, etc */
|
||||||
|
var hh = new URL(file, window.location.href);
|
||||||
|
window.location = hh.href;
|
||||||
|
} else {
|
||||||
|
window.location = '/play/play.jim?' +
|
||||||
|
'dir=' + encodeURIComponent(dir) +
|
||||||
|
'&base=' + encodeURI(window.location.href) +
|
||||||
|
'&duration=' + duration +
|
||||||
|
'&file=' + encodeURIComponent(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
$(it).dialog('close');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bind dialogue open to filenames.
|
// Bind dialogue open to filenames.
|
||||||
|
@ -828,11 +861,9 @@ $('a.bf').click(function(e) {
|
||||||
$dialog.attr('file', file);
|
$dialog.attr('file', file);
|
||||||
$dialog.attr('type', type);
|
$dialog.attr('type', type);
|
||||||
|
|
||||||
if (type == 'ts' &&
|
if (!(type == 'ts' &&
|
||||||
(opt.attr('odencd') == 0 || opt.attr('dlna') == 1))
|
(opt.attr('odencd') == 0 || opt.attr('dlna') == 1)))
|
||||||
$dialog.dialog("option", "buttons", $buttonsp);
|
$('#play').button('disable');
|
||||||
else
|
|
||||||
$dialog.dialog("option", "buttons", $buttons);
|
|
||||||
$dialog.dialog('open');
|
$dialog.dialog('open');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue