2017-08-31 34 views
1

(AM試圖整合下面的代碼到我ionic3項目的音樂將發揮但皮膚圖像不會顯示任何幫助。)怎麼我的繆斯女神JS融入我的離子三期工程

注:我想要在我的ionic 3應用程序中使用muse javascript API添加一個直播流媒體電臺。

<pre> 
    <script type="text/javascript" src="https://hosted.muses.org/mrp.js"> 
      </script> 
      <script type="text/javascript"> 
      MRP.insert({ 
      'url':'http://104.247.79.188:8000/kapitalfm929', 
      'lang':'en', 
      'codec':'mp3', 
      'volume':100, 
      'autoplay':true, 
      'jsevents':true, 
      'buffering':0, 
      'title':'KFM', 
      'welcome':'Station', 
      'wmode':'transparent', 
      'skin':'repvku-100', 
      'width':100, 
      'height':25 
      }); 
      </script> 

<pre> 
+0

你能告訴我們關於你的用例的更多細節嗎? – Sampath

+0

這是做Ionic 3應用程序的一個可怕的方式。請告訴我們你需要做什麼,然後我們會建議你一個正確的方法來做到這一點。 – Sampath

+0

好吧,我想添加一個livestreaming FM站到我的離子3應用程序使用muse JavaScript API「https://hosted.muses.org/mrp.js」 –

回答

0

您可以創建電臺播放器的基本演示與playpause按鈕,如下圖所示。

無線電player.ts

export class RadioPlayer { 
    url:string; 
    stream:any; 
    promise:any; 

constructor() { 
    this.url = "http://akalmultimedia.net:8000/GDNSLDH"; 
    this.stream = new Audio(this.url); 
}; 

play() { 
    this.stream.play(); 
    this.promise = new Promise((resolve,reject) => { 
    this.stream.addEventListener('playing',() => { 
     resolve(true); 
    }); 

    this.stream.addEventListener('error',() => { 
     reject(false); 
    }); 
    }); 

    return this.promise; 
}; 

pause() { 
    this.stream.pause(); 
}; 

} 

的.html

<ion-navbar *navbar> 
    <ion-title> Radio Player </ion-title> 
</ion-navbar> 

<ion-content class="home"> 
    <button dark (click)="play()"> 
    <ion-icon name="play"></ion-icon> 
    </button> 
    <button dark (click)="pause()"> 
    <ion-icon name="pause"></ion-icon> 
    </button> 
</ion-content> 

你可以閱讀更多關於this here。不過,這是Ionic 2 app.So使用得當你Ionic 3應用。

+0

請使用此插件for Ionic 3+ [https://ionicframework.com/docs/native/streaming-media/] –

+1

謝謝你現在工作得很好 –