Howler JS不会播放直播或LONG LONG DELAY

时间:2018-06-04 20:10:55

标签: howler.js

我遇到了Howler JS播放直播的问题。我在应用程序中使用相同的流,它可以正常播放。它不是流的问题。有时它可以工作,有时候......它需要永远加载或现在它不玩。

我在这里做错了什么?感谢

   <script src="/vmp/howler/dist/howler.js"></script>
<script>
    $( document ).ready(function() {
        console.log( "ready!" );
    $( "#Stop" ).hide();

    var URL = null;
    var sound = null;

    function LoadSound()
      {
        console.log('Sound Loaded');
        sound = new Howl({
            src: [URL],
            html5: true, // A live stream can only be played through HTML5 Audio.
            format: ['mp3', 'aac']
          });
        // Begin playing the sound.
      }


      $( "#Play" ).click(function() {
      //alert( "Handler for .click() called." );
        sound.play();
        $( "#Play" ).hide();
        $( "#Stop" ).css("visibility","visible");
        $( "#Stop" ).show();
        });

        $( "#Stop" ).click(function() {
      //alert( "Handler for .click() called." );
        sound.stop();
        $( "#Play" ).show();
        $( "#Stop" ).hide(); 
        });

      $.ajax({
      url: "getURL.php",
      type: "get",
      success: function(response) {
        //Do Something
        console.log(response);
        var obj = jQuery.parseJSON( response);
        console.log( obj.url );
        URL = obj.url;
        LoadSound();
      },
      error: function(xhr) {
        //Do Something to handle error
        console.log('oh noooo');
      }
    });

    });
    </script>

0 个答案:

没有答案