/**
 * Created with JetBrains WebStorm.
 * User: dfwang
 * Date: 14-7-16
 * Time: 上午10:23
 * To change this template use File | Settings | File Templates.
 */
define(function (require, exports) {
    var IOUtil;
    if (RunningPlatform === "NodeWebkit") {
        IOUtil = require("../../../../share/assert/js/ioutil_desktop.js").IOUtil;
    }
    else if (RunningPlatform === "Android") {
        IOUtil = require("../../../../share/assert/js/ioutil_android.js").IOUtil;
    }
    else if (RunningPlatform === "CEF") {
        IOUtil = require("../../../../share/assert/js/ioutil_cef.js").IOUtil;
    }
    else{
        IOUtil = require("../../../../share/assert/js/ioutil_web.js").IOUtil;
    }

    function getSourceDom(path) {
        var _str = '';
        switch (getExtName(path)) {
            case "mp3":
                _str = '<audio src="' + path + '" type="audio/mpeg"  controls="controls" ></audio>';
                break
            case "ogg":
                _str = '<audio src="' + path + '" type="audio/ogg"  controls="controls" ></audio>';
                break
            case "wav":
                _str = '<audio src="' + path + '" type="audio/wav"  controls="controls" ></audio>';
                break
        }
        return _str;
    }

    //获取扩展名
    function getExtName(url) {
        var _name = null;
        _name = url.split(".");
        _name = _name[_name.length - 1];
        return _name.toLowerCase();
    };

    fabric.Audio.prototype.getRenderDOM = function (relatedResPath) {
        var def = $.Deferred();
        //  var _dom = $('<audio src="'+relatedResPath+'" controls="controls" ></audio>')
        var _dom = $(getSourceDom(relatedResPath));
        def.resolve(_dom);
        return def.promise();
    };
});