Azure的媒体播放器Silverlight的后备不灵[修正] [英] Azure Media Player Silverlight fallback not working [Fixed]

查看:356
本文介绍了Azure的媒体播放器Silverlight的后备不灵[修正]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用蔚蓝色的媒体播放器,我的项目,它将发挥多种自适应比特率在一个asp.net页面流视频,最好的部分是,它是工作在HTML5和Flash精湛,但它会被停留在微调图像在Silverlight回落。

I have used the azure media player with my project, it will play multiple adaptive bit rate streamed videos in an asp.net page, the best part is, it is working superb in html5 and flash but it will get stuck at spinner image in silverlight fallback.

下面是code我都用过。

Below is the code I have used.

我也试图让错误,但它不打事件监听器code增加了错误,但该剧并在使用Flash和HTML5暂停事件工作正常,但Silverlight的回退不工作

I have also tried to get errors but it is not hitting the event listener code added for errors, but the play and pause events are working fine where flash and html5 is used, but silverlight fallback is not working at all.

<link href="https://amp.azure.net/libs/amp/1.3.0/skins/amp-default/azuremediaplayer.min.css" rel="stylesheet">
<script src="https://amp.azure.net/libs/amp/1.3.0/azuremediaplayer.min.js"></script>
<div class="marginBlock">
<h3>
    <asp:Label ID="lblTitle" runat="server"><%=Title.ToString()%></asp:Label>
</h3>
<video id="<%=mediaPlayerID %>" class="azuremediaplayer amp-default-skin amp-big-play-centered">
    <p class="amp-no-js">
        To view this video please enable JavaScript, and consider upgrading to a web browser that supports HTML 5 video.
    </p>
</video>
</div>
<p>
    <asp:Label ID="lblDescription" runat="server"><%=Description.ToString()%>
    </asp:Label>
</p>
<script>
 $(document).ready(function () {
    var playOptions = {
        "nativeControlsForTouch": false,
        techOrder: ['azureHtml5JS', 'flashSS', 'silverlightSS', 'html5'],
        autoplay: false,
        controls: true,
        width: '100%',
        height: '400',
        logo: { enabled: false },
        poster: "<%=ImageSelector%>"
    }

    var azurePlayer = amp('<%=mediaPlayerID%>', playOptions);
    azurePlayer.src([{
        src: "<%=VideoURL%>",
        type: 'application/vnd.ms-sstr+xml'
    }]);

    azurePlayer.addEventListener("error", function () {
        var errorDetails = azurePlayer.error();
        var code = errorDetails.code;
        var message = errorDetails.message;
        alert(errorDetails + ' ' + code + " " + message);
        if (azurePlayer.error().code & amp.errorCode.abortedErrStart) {
            console.log("abortedErrStart");
        }
        else if (azurePlayer.error().code & amp.errorCode.networkErrStart) {
            // MEDIA_ERR_NETWORK errors
            console.log("networkErrStart");
        }
        else if (azurePlayer.error().code & amp.errorCode.decodeErrStart) {
            // MEDIA_ERR_DECODE errors
            console.log("decodeErrStart");
        }
        else if (azurePlayer.error().code & amp.errorCode.srcErrStart) {
            // MEDIA_ERR_SRC_NOT_SUPPORTED errors
            console.log("srcErrStart");
        }
        else if (azurePlayer.error().code & amp.errorCode.encryptErrStart) {
            // MEDIA_ERR_ENCRYPTED errors
            console.log("encryptErrStart");
        }
        else if (azurePlayer.error().code & amp.errorCode.srcPlayerMismatchStart) {
            // SRC_PLAYER_MISMATCH errors
            console.log("srcPlayerMismatchStart");

        }
        else {
            // unknown errors
            console.log("unknown");
        }

    });

    azurePlayer.addEventListener('play', function () {
        console.log('play');
    });
    azurePlayer.addEventListener('pause', function () {
        console.log('pause');
    });
});

更新
注意到我收到以下为IE&LT误差; 11。

Updated Noticed I am getting following error for IE < 11.

该错误是蔚蓝的JS的精缩版

我也禁用在Firefox的Flash和移除techOrder Silverlight的,那么就应该打在错误事件侦听器,它没有击中。

Also I disabled the flash in firefox and removed the silverlight from techOrder, then it should hit the error event listener, it is not hitting.

这也很重要,对我来说,处理分析错误。
播放和暂停事件侦听器工作正常。

This is also important for me to handle the analytics for error. Play and Pause event listener are working fine.

更新2015年8月28日:
修正了JS错误,这是因为多个呼叫在连接上述蔚蓝的CDN的,感动在母版页中code和加载它只有一次,就像Chrome浏览器处理code容易,但不是IE的口是心非。

Update 8/28/2015: Fixed the JS error, it is because of multiple call to cdn of azure mentioned in link above, moved the code in master page and load it only once, browser like chrome handles duplicity of code easily but not IE.

我的全部失去,为什么它不工作的研究之后。
因此,增加了以下JS将检查Silverlight和Flash和适当地处理错误和更新我们的分析也是如此。

After all the research I am lost why it is not working. So added the following JS that will check for Silverlight and Flash and gracefully handle the error and update our analytics as well.

function getBrowserInformation() {
 var ua = navigator.userAgent, tem, M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
if (/trident/i.test(M[1])) {
    tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
    return { name: 'IE ', version: (tem[1] || '') };
}
if (M[1] === 'Chrome') {
    tem = ua.match(/\bOPR\/(\d+)/)
    if (tem != null) { return { name: 'Opera', version: tem[1] }; }
}
M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];
if ((tem = ua.match(/version\/(\d+)/i)) != null) { M.splice(1, 1, tem[1]); }
return {
    name: M[0],
    version: M[1]
};};

function checkForAzureErrors() {
 function isSilverlightInstalled() {
    var isSilverlightInstalled = false;

    try {
        //check on IE
        try {
            var slControl = new ActiveXObject('AgControl.AgControl');
            isSilverlightInstalled = true;
        }
        catch (e) {
            //either not installed or not IE. Check Firefox/Safari
            if (navigator.plugins["Silverlight Plug-In"]) {
                isSilverlightInstalled = true;
            }
        }
    }
    catch (e) {
        console.log(e);
    }
    return isSilverlightInstalled;
}

function isFlashInstalled() {
    try {
        return Boolean(new ActiveXObject('ShockwaveFlash.ShockwaveFlash'));
    } catch (exception) {
        return ('undefined' != typeof navigator.mimeTypes['application/x-shockwave-flash']);
    }
}

function addErrorMessage() {
    $($("#mediaPlayer.marginBlock").find('h3')).text('Media is not supported on this browser or device.');
    $($("#mediaPlayer.marginBlock").find('video')).css('display', 'none');
    $($("#mediaPlayer.marginBlock").find('p')).css('display', 'none');
    $('.azuremediaplayer').css('display', 'none');
    ga("send", "event", "Videos", "error",
                        getBrowserInformation().name + getBrowserInformation().version +
                        ": is silverlight Installed " + isSilverlightInstalled() +
                        " and is Flash Installed " + isFlashInstalled());
}

function checkBrowser() {
    if ((getBrowserInformation().name === 'MSIE' || getBrowserInformation().name === 'IE')) {
        if (getBrowserInformation().version < 11) {
            addErrorMessage();
        }
    } else if (getBrowserInformation().name === 'Firefox') {
        addErrorMessage();
    }
}

if ((getBrowserInformation().name === 'MSIE' || getBrowserInformation().name === 'IE')) {
    if (getBrowserInformation().version < 9) { addErrorMessage() }
}

for (var key in amp.players) {
    if (amp.players.hasOwnProperty(key)) {
        if (isSilverlightInstalled()) {
            if (!amp.players[key].isReady_) {
                checkBrowser();
            }
        } else if (!isFlashInstalled()) {
            checkBrowser();
        }
    }
}}

此功能在功能的document.ready页面加载5秒后叫,给它足够的时间来加载,使isReady_boolean真实的。

This function is called after 5 second of page load in document.ready function, giving it enough time to load and make the isReady_boolean true.

 SetTimeout(function () { checkForAzureErrors(); }, 5000);

不过我在等待了一个天使来解决这个问题。

Still I am waiting for some angel to resolve this issue.

更新:局部固定

需要添加XAP refrences像老版本,它将发挥silverlight的,但有一个陷阱,如果你有一个每页视频时才会有效。

Need to add the xap refrences like older version, it will play silverlight but there is a catch, it will only work if you have one video per page.

<script>
        amp.options.flashSS.swf = "http://amp.azure.net/libs/amp/1.3.0/techs/StrobeMediaPlayback.2.0.swf"
        amp.options.flashSS.plugin = "http://amp.azure.net/libs/amp/1.3.0/techs/MSAdaptiveStreamingPlugin-osmf2.0.swf"
        amp.options.silverlightSS.xap = "http://amp.azure.net/libs/amp/1.3.0/techs/SmoothStreamingPlayer.xap"
</script>

更新:2015年8月29日

根据从阿米特拉杰普特

@Parshii目前,根据文档,Azure的媒体播放器不支持多实例回放。虽然它可能在一些技术人员的工作,它不是在此时测试情形。请随时将其添加到UserVoice的论坛( http://aka.ms/ampuservoice )。

@Parshii Currently, as per the documentation, Azure Media Player doesn't support multi-instance playback. While it may work on some techs, it is not a tested scenario at this time. Please feel free to add it to the UserVoice forum (http://aka.ms/ampuservoice).

根据我的测试它工作在HTML5和Flash,但不是的Silverlight,Silverlight的支持,我们可以尝试使用内部框架按从评论rnrneverdies

As per my testing it is working in html5 and flash but not Silverlight, for silverlight support we can try using iframes as per comments from rnrneverdies

单实例媒体播放器工作在所有的科技股。

Single Instance Media Player is working in all techs.

推荐答案

@Parshii目前,根据文档,Azure的媒体播放器不支持多实例回放。虽然它可能在一些技术人员的工作,它不是在此时测试情形。请随时将其添加到UserVoice的论坛( http://aka.ms/ampuservoice )。

@Parshii Currently, as per the documentation, Azure Media Player doesn't support multi-instance playback. While it may work on some techs, it is not a tested scenario at this time. Please feel free to add it to the UserVoice forum (http://aka.ms/ampuservoice).

这篇关于Azure的媒体播放器Silverlight的后备不灵[修正]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆