如何在离子2中播放rtsp直播视频?

时间:2018-03-30 09:44:44

标签: cordova ionic-framework rtsp live-streaming

我无法在我的离子应用程序CordovaStreamingMedia,cordova-rtsp中播放合适的插件来播放rtsp视频,但没有成功。请帮忙

1 个答案:

答案 0 :(得分:1)

在离子项目中安装此插件。

List<Integer> diffList = new ArrayList<>(CollectionUtils.subtract(NATURAL_MANDATORY, MandatoryList));

=========================== .ts ================== ===============

ionic cordova plugin add cordova-plugin-streaming-media
npm install --save @ionic-native/streaming-media

========================= HTML ===================== =

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();
}