577
577
$("#filesbody").append(div);
580
/** Displays a video.
582
function handle_video(path, type)
584
/* Disable save button and hide the save panel */
585
using_codepress = false;
589
var url = app_url(service_app, path) + "?return=contents";
590
var download_url = app_url(download_app, path);
592
/* Fallback Download Link */
593
var link = $('<p>Could not display video in browser.<p><p><a /></p>');
594
var a = link.find('a');
595
a.attr("href", download_url);
596
a.text("Download " + path);
598
/* Fallback Object Tag */
599
var obj = $('<object />');
600
obj.attr("type", type);
601
obj.attr("data", url);
604
/* HTML 5 Video Tag */
605
var video = $('<video controls="true" autoplay="true" />');
606
video.attr("src", url);
607
var support = video[0].canPlayType && video[0].canPlayType(type);
608
if (support != "probably" && support != "maybe") {
614
var div = $('<div class="padding" />');
615
div.append('<h1>Video Preview</h1>');
617
$("#filesbody").append(div);
620
/** Display audio content
622
function handle_audio(path, type)
624
/* Disable save button and hide the save panel */
625
using_codepress = false;
629
var url = app_url(service_app, path) + "?return=contents";
630
var download_url = app_url(download_app, path);
632
/* Fallback Download Link */
633
var link = $('<p>Could not display audio in browser.<p><p><a /></p>');
634
var a = link.find('a');
635
a.attr("href", download_url);
636
a.text("Download " + path);
638
/* Fallback Object Tag */
639
var obj = $('<object />');
640
obj.attr("type", type);
641
obj.attr("data", url);
644
/* HTML 5 Audio Tag */
645
var audio = $('<audio controls="true" autoplay="true" />');
646
audio.attr("src", url);
647
var support = audio[0].canPlayType && audio[0].canPlayType(type);
648
if (support != "probably" && support != "maybe") {
654
var div = $('<div class="padding" />');
655
div.append('<h1>Audio Preview</h1>');
580
/* Displays a media file using an HTML5 <audio> or <video> tag.
581
* Falls back to <object> if the format is unsupported.
583
function handle_html5_media(path, type, tag_name)
585
/* Disable save button and hide the save panel */
586
using_codepress = false;
590
var url = app_url(service_app, path) + "?return=contents";
591
var download_url = app_url(download_app, path);
593
/* Fallback download link */
595
'<p>Could not play ' + tag_name + ' file. ' +
596
'Try <a>downloading it</a> instead.</p>');
597
link.find('a').attr("href", download_url);
599
/* HTML 5 media element */
600
var html5_element = $(
601
'<' + tag_name + ' controls="true" autoplay="true" />');
602
html5_element.attr("src", url);
603
var support = (html5_element[0].canPlayType &&
604
html5_element[0].canPlayType(type));
606
/* If the browser thinks it might be able to play it, use the HTML5
607
* element. Otherwise, fall back to an <object>, which might work.
609
if (support == "probably" || support == "maybe") {
610
var element = html5_element;
612
var element = $('<object />');
613
element.attr("type", type);
614
element.attr("data", url);
616
element.append(link);
619
var div = $('<div class="padding" />');
620
div.append('<h1>File preview</h1>');
657
622
$("#filesbody").append(div);