如何在 ionic 2 中播放 rtsp 实时视频?
How to play rtsp live video in ionic 2?
我无法获得合适的插件来在我的 ionic app.tried CordovaStreamingMedia,cordova-rtsp 中播放 rtsp 视频,但没有 success.Pls 帮助
在 ionic 项目中安装此插件。
ionic cordova plugin add cordova-plugin-streaming-media
npm install --save @ionic-native/streaming-media
===========================.ts ================ =================
import { NavController, ToastController } from 'ionic-angular';
import { StreamingMedia, StreamingVideoOptions, StreamingAudioOptions } from '@ionic-native/streaming-media';
constructor(public navCtrl: NavController,
public toastCtrl: ToastController,
private streamingMedia: StreamingMedia) { }
startVideo(){
let options: StreamingVideoOptions = {
successCallback: () => { this.tost('Video played'); },
errorCallback: (e) => { this.tost(JSON.stringify(e)); },
orientation: 'landscape',
// orientation: 'portrait'
};
this.streamingMedia.playVideo(**'YOUR_LIVE_STREAMING_URL'**, options);
}
tost(message){
let toast = this.toastCtrl.create({
message: message,
duration: 3000
});
toast.present();
}
========================= HTML =============== =======
<ion-card>
<button ion-button (click)="startVideo()">Start Video</button>
</ion-card>
我无法获得合适的插件来在我的 ionic app.tried CordovaStreamingMedia,cordova-rtsp 中播放 rtsp 视频,但没有 success.Pls 帮助
在 ionic 项目中安装此插件。
ionic cordova plugin add cordova-plugin-streaming-media
npm install --save @ionic-native/streaming-media
===========================.ts ================ =================
import { NavController, ToastController } from 'ionic-angular';
import { StreamingMedia, StreamingVideoOptions, StreamingAudioOptions } from '@ionic-native/streaming-media';
constructor(public navCtrl: NavController,
public toastCtrl: ToastController,
private streamingMedia: StreamingMedia) { }
startVideo(){
let options: StreamingVideoOptions = {
successCallback: () => { this.tost('Video played'); },
errorCallback: (e) => { this.tost(JSON.stringify(e)); },
orientation: 'landscape',
// orientation: 'portrait'
};
this.streamingMedia.playVideo(**'YOUR_LIVE_STREAMING_URL'**, options);
}
tost(message){
let toast = this.toastCtrl.create({
message: message,
duration: 3000
});
toast.present();
}
========================= HTML =============== =======
<ion-card>
<button ion-button (click)="startVideo()">Start Video</button>
</ion-card>