Ionic framework 离子流媒体插件问题
我正在尝试构建一个ionic应用程序来流式传输音频源 这是我到目前为止所拥有的 app.module.tsIonic framework 离子流媒体插件问题,ionic-framework,ionic3,Ionic Framework,Ionic3,我正在尝试构建一个ionic应用程序来流式传输音频源 这是我到目前为止所拥有的 app.module.ts import { BrowserModule } from '@angular/platform-browser'; import { ErrorHandler, NgModule } from '@angular/core'; import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular'; import
import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { StreamingMedia } from '@ionic-native/streaming-media';
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
@NgModule({
declarations: [
MyApp,
HomePage
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage
],
providers: [
StatusBar,
SplashScreen,
StreamingMedia,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
})
export class AppModule {}
home.ts
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { StreamingMedia, StreamingAudioOptions } from '@ionic-native/streaming-media';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(public navCtrl: NavController, private streamingMedia: StreamingMedia) {
}
playStream() {
let options: StreamingAudioOptions = {
bgColor: 'red',
successCallback: () => { console.log('Audio played') },
errorCallback: (e) => { console.log('Error streaming') }
};
this.streamingMedia.playAudio('http://listen.radionomy.com:80/NewYorkClassicRock');
}
}
home.html
<ion-header>
<ion-navbar>
<ion-title>
Ionic Blank
</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
The world is your oyster.
<p>
If you get lost, the <a href="http://ionicframework.com/docs/v2">docs</a> will be your guide.
</p>
<button ion-button large (click)="playStream()">Start the Stream!</button>
</ion-content>
离子空白
世界就是你的牡蛎。
如果你迷路了,那条路将是你的向导。
开始吧!
使用ionic view,在android或ios中单击按钮不会执行任何操作
我做错了什么或错过了什么
谢谢 它在离子视图中不起作用。 使用以下命令在物理设备上运行: cordova运行android——调试
从你的应用文件夹中 一个小观察,您正在设置选项,但没有将其传递到
流媒体
。您可能需要执行以下操作:
this.streamingMedia.playAudio('http://listen.radionomy.com:80/NewYorkClassicRock",选择),;
使用离子视图。。插件不能与爱奥尼亚服务一起使用,因为没有加载cordova。你必须使用设备/模拟器。。我也使用了相同的代码来调用插件。对我来说很好。虽然音频流链接是错误的,但它对我来说非常好。