https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 28c8debd4209bd796cc84032359b566eac9a6838 authored by Darren Shen on 11 April 2018, 06:04:13 UTC
[css-typed-om] Support remaining text properties.
Tip revision: 28c8deb
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