怎么我的缪斯女神JS融入我的离子三期工程

问题描述:

(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” –

您可以创建电台播放器的基本演示与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

谢谢你现在工作得很好 –