Ionic 2播放中央电视台视频

时间:2017-05-10 14:07:57

标签: angular ionic2

我使用离子框架和cordova开发了App。

我需要播放闭路电视视频。

我的收藏品

 {
  "0" : {
    "ACCESS_USERS" : [ {
      "FLAT_ID" : "1_1",
      "USER_ID" : "1"
    }, {
      "FLAT_ID" : "4",
      "USER_ID" : "6"
    }, {
      "FLAT_ID" : "5",
      "USER_ID" : "7"
    } ],
    "APART_ID" : "2",
    "CAMERA_ACCESS_CODE" : "1234",
    "CAMERA_ACCESS_URL" : "http://192.168.0.200",
    "CAMERA_CODE" : "G1_C1",
    "CAMERA_NAME" : "Ground floor entrance camera 1",
    "CAMERA_PASSWORD" : "admin",
    "CAMERA_STATUS" : "1",
    "CAMERA_USERNAME" : "admin"
  }

}

我不知道。

请建议我,

感谢。

1 个答案:

答案 0 :(得分:1)

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

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

使用您的收藏集制作一个实时流媒体网址。

演示网址=' http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_30mb.mp4'

=========================== .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>