BaiduMusic / muplayer

An open source web audio player from Baidu Music, support HTML5 and Flash engine on different platforms(百度音乐播放内核)
https://886.enimo.cn/muplayer/doc/
Other
938 stars 226 forks source link

flash 内核在暂停的时候不会派发 progress 事件 #72

Open JrIdeA opened 9 years ago

JrIdeA commented 9 years ago

flash 内核在暂停的时候不会派发 progress 事件,而这时还在缓冲。audio 内核正常。

以下演示代码,可以切换不同内核播放暂停看看进度条

<body>
    <button id="pause">暂停</button>
    <button id="play">播放</button>
    <div style="width:300px;height:10px;background:#ccc;">
        <div id="progress" style="width:0;height:10px;background:#6cf;"></div>
    </div>

<script>
var flashMP3Core = {
    constructor: 'FlashMP3Core',
    args: {
        swf: 'muplayer_mp3.swf?' + +new Date(),
        expressInstaller: 'expressInstall.swf'
    }
},
flashMP4Core = {
    constructor: 'FlashMP4Core',
    args: {
        swf: 'muplayer_mp4.swf?' + +new Date(),
        expressInstaller: 'expressInstall.swf'
    }
},
audioCore = {
    constructor: 'AudioCore'
};

var player = new _mu.Player({
    baseDir: '/',
    absoluteUrl: false,
    engines: [flashMP3Core/* audioCore */]
});

player.on('progress', function(per){
    console.log(per);
    $('#progress').css('width', per*100+'%');
})

$('#play').click(function(){
    player.play();
});

$('#pause').click(function(){
    player.pause();
});

player.add('//bs.baidu.com/lebo18/data2/music/7995224/7995224.mp3?xcode=0f1cb5226655fe9125e169321c1400f7ec59801e43c73961&sign=MBO:eJoqfLcbQdeO4Ienql6d8Matif5bip:/0eQ2S9K4ulWqY9dKJNNSRaWwz0%3D').play();
</script>
</body>