Flowplayer 重叠播放同一曲目两次

发布于 2024-12-28 14:41:15 字数 1274 浏览 5 评论 0 原文

我的想法是在用户离开此页面或重新加载页面时立即保存播放器的当前状态(“播放”、“暂停”或“停止”)、播放列表和曲目时间。一旦页面重新加载,播放器就应该从最后一个位置(时间)继续播放最后一个曲目(如果我们在播放器播放时重新加载页面)。

但我面临着一种奇怪的行为。当播放器正在播放曲目并且我重新加载页面时,播放器会执行我想要的操作,而且它会播放相同的曲目两次,彼此重叠一件事,您可以控制一个曲目,但我不知道另一个曲目在哪里一个在玩?

尝试暂停然后播放,看看是否有两个曲目正在播放。

下面是加载播放列表的代码,调用 play() ,然后 flowplayer

            function reLoadPlaylist(id){
                $f(id).play(playlist);
                $f(id).pause();
                window.setTimeout(function(){
                    $f(id).seek(currentTime);
                    switch(playState){
                      case 'play':
                          $f(id).resume();
                          break;
                      case 'pause':
                          $f(id).pause();
                          break;
                      case 'stop':
                          $f(id).stop();
                          break;
                    }
                  },2000);
                }

播放列表的eek() 是一个 JSON 对象,如果定义的话,它看起来像这样:

    playlist: [{
      url : 'framing.mp3',
      title : 'Farming'
    }]

知道出了什么问题吗? 查看实时(网址已更新)的行为

My idea is to save the player's current state("play", "pause" or "stop"), playlist and the track's time as soon as user navigates away from this page or reloads it. As soon as the page reloads, the player should continue playing last track (if we reloaded the page when player was playing) from the last location (time).

But I'm facing a strange behaviour. When the player is playing the track and I reload the page, the player, it does does what I wanted plus it plays the same track twice overlapping each other One more thing, you can control one track but I don't know where the other one is playing?

Try to pause and then play to see if two tracks are playing.

Here's the code that loads the playlist, calls play() and then seek() of flowplayer

            function reLoadPlaylist(id){
                $f(id).play(playlist);
                $f(id).pause();
                window.setTimeout(function(){
                    $f(id).seek(currentTime);
                    switch(playState){
                      case 'play':
                          $f(id).resume();
                          break;
                      case 'pause':
                          $f(id).pause();
                          break;
                      case 'stop':
                          $f(id).stop();
                          break;
                    }
                  },2000);
                }

playlist is a JSON object, if defined it looks like this:

    playlist: [{
      url : 'framing.mp3',
      title : 'Farming'
    }]

Any idea what's wrong?
Check out the behaviour live (URL Updated)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

表情可笑 2025-01-04 14:41:15

作为记录,我将其添加为答案。
因此重新发布我的评论作为答案。

好吧,我自己已经想出来了! $f(id).pause(),在 $f(id).play() 导致问题之后。这个问题从我这边已经结束了。感谢@RyanKina 的帮助

For the record, I am adding this as the answer.
So re posting my comment as an answer.

Ok, I have figured it out my self! $f(id).pause(), after the $f(id).play() caused the problem. This question is closed from my side. thanks to @RyanKina for helping

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文