[dancer-users] setting mime type

Mr. Puneet Kishor punk.kish at gmail.com
Sun Jun 30 07:51:35 BST 2013


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


More information about the dancer-users mailing list