angularJS audio IE兼容性

时间:2015-09-18 13:05:42

标签: angularjs audio

我正在尝试使用html5音频,现在它可以使用chrome和firefox顺利运行。我在使用IE时遇到了一些问题。在IE中,当音频结束时,播放/暂停按钮不会改变。它仍然是播放图标,我想要的是显示暂停图标。我的代码如下:

<section ng-show="audio.canPlay">
    <a class="star" ng-show="audio.paused" ng-click='audio.play()'></a>
    <a class="star s-pause" ng-hide="audio.paused" ng-click='audio.pause()'></a>
</section>

var isProgessMove = false;
scope.clickPlayProgess = function (evt) {
    evt.stopPropagation();
    var now = (evt.offsetX / $(evt.target).parent().width());
    scope.audio.progress = (formatRange(now));
}
scope.mousedownPlayBar = function (evt) {
    isProgessMove = true;
    scope.lastScreenX = -($(evt.target).parent().width()) + evt.screenX;
    $(document).on('mousemove', movePlayPorgess);
    $(document).on('mouseup', mouseupProgessBar);
}
var movePlayPorgess = function (evt) {
    if (isProgessMove) {
        scope.$apply(function () {
            var now = (evt.screenX - scope.lastScreenX) / 398;
            scope.audio.progress = formatRange(now);
        })
    }
}
var mouseupPorgessBar = function () {
    isPorgessMove = false;
    $(document).off('mousemove');
    $(document).off('mouseup');
}

1 个答案:

答案 0 :(得分:0)

是的,我知道,那是因为ngaudio没有打包“audio.ended”,你可以自己动手。

<section ng-show="audio.canPlay">
    <a class="star" ng-show="audio.paused || audio.audio.ended" ng-click='audio.play()'></a>
    <a class="star s-pause" ng-hide="audio.paused || audio.audio.ended" ng-click='audio.pause()'></a>
</section>