www/browser/Media.js
function createNode (media) {
    var node = new Audio();

    node.onplay = function () {
        Media.onStatus(media.id, Media.MEDIA_STATE, Media.MEDIA_STARTING);
    };

    node.onplaying = function () {
        Media.onStatus(media.id, Media.MEDIA_STATE, Media.MEDIA_RUNNING);
    };

    node.ondurationchange = function (e) {
        Media.onStatus(media.id, Media.MEDIA_DURATION, e.target.duration || -1);
    };

    node.onerror = function (e) {
        // Due to media.spec.15 It should return MediaError for bad filename
        var err = e.target.error.code === MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED ?
            { code: MediaError.MEDIA_ERR_ABORTED } :
            e.target.error;

        Media.onStatus(media.id, Media.MEDIA_ERROR, err);
    };

    node.onended = function () {
        Media.onStatus(media.id, Media.MEDIA_STATE, Media.MEDIA_STOPPED);
    };

    if (media.src) {
        node.src = media.src;
    }

    return node;
}
function createNode (media) {
    var node = new Audio();

    node.onplay = function () {
        Media.onStatus(media.id, Media.MEDIA_STATE, Media.MEDIA_STARTING);
    };

    node.onplaying = function () {
        Media.onStatus(media.id, Media.MEDIA_STATE, Media.MEDIA_RUNNING);
    };

    node.ondurationchange = function (e) {
        Media.onStatus(media.id, Media.MEDIA_DURATION, e.target.duration || -1);
    };

    node.onerror = function (e) {
        // Due to media.spec.15 It should return MediaError for bad filename
        var err = e.target.error.code === MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED ?
            { code: MediaError.MEDIA_ERR_ABORTED } :
            e.target.error;

        Media.onStatus(media.id, Media.MEDIA_ERROR, err);
    };

    node.onended = function () {
        Media.onStatus(media.id, Media.MEDIA_STATE, Media.MEDIA_STOPPED);
    };

    if (media.src) {
        node.src = media.src;
    }

    return node;
}
function createNode ( media ) { var node = new Audio ( ) ; node . onplay = function ( ) { Media . onStatus ( media . id , Media . MEDIA_STATE , Media . MEDIA_STARTING ) ; } ; node . onplaying = function ( ) { Media . onStatus ( media . id , Media . MEDIA_STATE , Media . MEDIA_RUNNING ) ; } ; node . ondurationchange = function ( e ) { Media . onStatus ( media . id , Media . MEDIA_DURATION , e . target . duration || - 1 ) ; } ; node . onerror = function ( e ) { // Due to media.spec.15 It should return MediaError for bad filename var err = e . target . error . code === MediaError . MEDIA_ERR_SRC_NOT_SUPPORTED ? { code : MediaError . MEDIA_ERR_ABORTED } : e . target . error ; Media . onStatus ( media . id , Media . MEDIA_ERROR , err ) ; } ; node . onended = function ( ) { Media . onStatus ( media . id , Media . MEDIA_STATE , Media . MEDIA_STOPPED ) ; } ; if ( media . src ) { node . src = media . src ; } return node ; }
Creates new Audio node and with necessary event listeners attached
@param  {Media} media Media object
@return {Audio}       Audio element
Creates new Audio node and with necessary event listeners attached