代码之家  ›  专栏  ›  技术社区  ›  Ameya

如何在爱奥尼亚2中播放rtsp实时视频?

  •  -1
  • Ameya  · 技术社区  · 7 年前

    我无法获得合适的插件在我的ionic应用程序中播放rtsp视频。尝试了CordovaStreamingMedia、cordova rtsp,但没有成功。请帮忙

    1 回复  |  直到 7 年前
        1
  •  2
  •   Suraj Rao Raas Masood    7 年前

    在爱奥尼亚项目中安装此插件。

    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>