https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 55d48b7dd6daa53f4817a045cd559b570fadafc3 authored by Darren Shen on 15 March 2018, 05:06:57 UTC
[css-typed-om] Add support for flex properties.
Tip revision: 55d48b7
media.js
//
// Returns the URI of a supported video source based on the user agent
//
function getVideoURI(base)
{
    var extension = '.mp4';

    var videotag = document.createElement("video");

    if ( videotag.canPlayType  &&
         videotag.canPlayType('video/ogg; codecs="theora, vorbis"') )
    {
        extension = '.ogv';
    }

    return base + extension;
}

//
// Returns the URI of a supported audio source based on the user agent
//
function getAudioURI(base)
{
    var extension = '.mp3';

    var audiotag = document.createElement("audio");

    if ( audiotag.canPlayType &&
         audiotag.canPlayType('audio/ogg') )
    {
        extension = '.oga';
    }

    return base + extension;
}

function getMediaContentType(url) {
    var extension = new URL(url, location).pathname.split(".").pop();
    var map = {
        "mp4": "video/mp4",
        "ogv": "video/ogg",
        "mp3": "audio/mp3",
        "oga": "audio/ogg",
    };
    return map[extension];
}
back to top