I am sending back to the browser html5 video code via JSON as shown below. The code then loads mp4 video, but I need to set the correct mime type for the video. How do I do that with Dancer? get '/p/:uri' => sub { return to_json { html => qq{ <video width="960" height="540" poster="path/to/$mov.jpg" controls> <source type="video/mp4" src="path/to/$mov.mp4" /> <source type="video/m4v" src="path/to/$mov.m4v" /> <source type="video/ogg" src="path/to/$mov.ogv" /> <source type="video/webm" src="path/to/$mov.webm" /> Sorry, your browser has no video playback capabilities </video> <br /> <b>$title</b> }; }; }; Note that the "path/to/.." is relative to the Dancer app, so the video is being served by Dancer. For a totally orthogonal reason I am unable to serve the static files from a different web server. Many thanks, -- Puneet Kishor
Hi Puneet, A bit off-topic, but I had trouble with a similar setup, serving the video files with Dancer did not work for me (using the send_file method). Well, it worked everywhere, except on iOS devices (iPAd, iPhone). I had to resort (very unwillingly, there is a lot of access checking involved) to serving the videofiles via Apache, and the rest of the Dancer app proxie'd (using starman). My experience was that it had nothing to do with mime-types, but more with quirks in iOS, but I would love to be corrected on this. Hope this helps, Regards, Hermen Lesscher (A happy Dancer user) On 30/06/2013 08:51 , Mr. Puneet Kishor wrote:
I am sending back to the browser html5 video code via JSON as shown below. The code then loads mp4 video, but I need to set the correct mime type for the video. How do I do that with Dancer?
get '/p/:uri' => sub { return to_json { html => qq{ <video width="960" height="540" poster="path/to/$mov.jpg" controls> <source type="video/mp4" src="path/to/$mov.mp4" /> <source type="video/m4v" src="path/to/$mov.m4v" /> <source type="video/ogg" src="path/to/$mov.ogv" /> <source type="video/webm" src="path/to/$mov.webm" /> Sorry, your browser has no video playback capabilities </video> <br /> <b>$title</b> }; }; };
Note that the "path/to/.." is relative to the Dancer app, so the video is being served by Dancer. For a totally orthogonal reason I am unable to serve the static files from a different web server.
Many thanks,
-- Puneet Kishor _______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
-- "I urge you to please notice when you are happy, and exclaim or murmur or think at some point, 'If this isn't nice, I don't know what is.'" -- Kurt Vonnegut
On 13-06-30 02:51 AM, Mr. Puneet Kishor wrote:
but I need to set the correct mime type for the video. How do I do that with Dancer?
if you use 'send_file', Dancer will try to guess a decent miem type based on the file's extension. If not, you can manipulate the content type via 'response->content_type( 'some/type' )' Joy, `/anick
On Jul 1, 2013, at 10:18 AM, Yanick Champoux <yanick@babyl.dyndns.org> wrote:
On 13-06-30 02:51 AM, Mr. Puneet Kishor wrote:
but I need to set the correct mime type for the video. How do I do that with Dancer?
if you use 'send_file', Dancer will try to guess a decent miem type based on the file's extension.
If not, you can manipulate the content type via 'response->content_type( 'some/type' )'
I am going to reformulate my question. I have the following code -- In my browser <div id="content"></div> <script id="tmpl" type="text/x-handlebars-template"> {{{ text }}} </script> var tmpl = Handlebars.compile( $("#tmpl").html() ); $.ajax({ url : "/v/" + page, type : "GET", dataType: "json", error : function() { alert("Error loading html document"); }, success : function(res) { if (res == null) { return; } document.title = res.title; $("#content").html( tmpl( {text: res.text} ); ); } }); On my server get '/v/:page' => sub { my $page = param('page'); my ($title, $modified_on) = get_page($page); debug "sending back $uri"; my %tmpl_opts = ( title => $title, text => qq{ <video width="960" height="540" poster="path/to/movie.jpg" controls preload="auto"> <source type="video/mp4" src="path/to/movie.mp4" /> <source type="video/ogg" src="path/to/movie.ogv" /> <source type="video/webm" src="path/to/movie.webm" /> Sorry, your browser has no video playback capabilities </video> }, modified_on => $modified_on ); return to_json \%tmpl_opts; }; The above code works fine on all browsers on the desktop. However, on Safari on iPad the video is disabled. Dancer is running on Starman behind an Apache proxy. A static test page with the video code (no ajax, no JavaScript templates) served directly by Apache works fine even on Safari on iPad. What am I doing wrong, and how can I correct this? -- Puneet Kishor
participants (4)
-
Hermen Lesscher -
Mr. Puneet Kishor -
Puneet Kishor -
Yanick Champoux