【问题标题】:unable to auto-play with mediaelement js in chrome无法在 Chrome 中使用 mediaelement js 自动播放
【发布时间】:2019-02-21 20:47:38
【问题描述】:

我正在尝试从直播音频链接自动播放音频:http://163.172.165.94:8728/;stream.mp3

我尝试添加autoplay,然后这样做:

$('#player2').mediaelementplayer({
    autoplay: true
});

没有用,尝试了堆栈溢出的每一个答案。

有人可以帮助我吗?我做错了什么?

<link rel="stylesheet" href="https://cdn.jsdelivr.net/mediaelement/latest/mediaelementplayer.css">

<div class="media-wrapper">
<audio id="player2" preload="auto" autoplay style="max-width:100%;">
<source src="http://163.172.165.94:8728/;stream.mp3" type="audio/mp3">
 </audio>
</div>

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/mediaelement/latest/mediaelement-and-player.min.js"></script>
    <script>
    $('#player2').mediaelementplayer();
    </script>

【问题讨论】:

    标签: javascript mediaelement.js


    【解决方案1】:

    这将帮助您在加载时自动播放

    <audio id="player2" preload="auto" autoplay style="max-width:100%;">
          <source src="<?php echo $audidec; ?>" type="audio/mp3">
    </audio>
    
    
    $('audio').mediaelementplayer({
        success: function (mediaElement) {
            mediaElement.play();
            mediaElement.addEventListener('ended', function (e) {
                alert("finished");
            }, true);
        }
    });
    

    【讨论】:

      猜你喜欢
      • 2018-02-26
      • 1970-01-01
      • 1970-01-01
      • 2017-09-21
      • 1970-01-01
      • 1970-01-01
      • 2016-12-26
      • 2021-08-02
      • 1970-01-01
      相关资源
      最近更新 更多