2017-05-05 137 views
0

我正在嘗試構建一個廣播電臺的應用程序,但仍然遇到同樣的錯誤。如何從網站獲取mp3音頻流媒體網址?

這就是它給我的。

http://www.tantalk1340.com/wp-content/plugins/shoutcast-icecast-html5-radio-player/html5/html5icecast.php?id=7&caching=201&rand=2/

+0

你得到了什麼錯誤?你是否試圖以一次性或編程方式做到這一點?如果是一次性的,只需在您的開發人員工具中查看網絡請求並查找實際的流式URL。 (該URL用於網頁。)如果以編程方式執行此操作,則需要解析HTML。 – Brad

回答

0

它可以讓你將生成一個播放器的HTML頁面中的鏈接。你可以打開鏈接,它有很好的JavaScript代碼。下面是一個片段,說怎麼弄流:

   var currentTime = Date.now() || +new Date(); 

       var stream = { 
        title: "Tan Talk 1340 AM", 
        mp3: "http://home.besedic.com:8000/live?hash="+currentTime 
       }, 
       ready = false; 

       jQuery("#jquery_jplayer_1").jPlayer({ 
        ready: function (event) { 
         ready = true; 

         if(autoplayz==false) 
         jQuery(this).jPlayer("setMedia", stream); 
         else 
         jQuery(this).jPlayer("setMedia", stream).jPlayer("play"); 


        }, 
        pause: function() { 
         jQuery(this).jPlayer("clearMedia"); 
        }, 
        error: function(event) { 
         if(ready && event.jPlayer.error.type === jQuery.jPlayer.error.URL_NOT_SET) { 
          // Setup the media stream again and play it. 
          jQuery(this).jPlayer("setMedia", stream).jPlayer("play"); 
         } 
        }, 
        swfPath: "js", 
        supplied: "mp3", 
        preload: "auto", 
        wmode: "window", 
        /*autoPlay: true,*/ 
        solution:"flash,html", 
        volume: vol/100, 
        keyEnabled: true 
       }); 

如果它不是來自片段清楚,你的URL是: HTTP://home.besedic.com:8000 /住哈希= + currentTime的

image