Hi.
I already added “/ngx” to related imports but I still get ;
TypeError: Object(...) is not a function
at StreamingMedia.playVideo (http://localhost:8100/build/vendor.js:82539:147)
at HomePage.webpackJsonp.262.HomePage.play (http://localhost:8100/build/main.js:67:29)
at Object.eval [as handleEvent] (ng:///AppModule/HomePage.ngfactory.js:37:27)
at handleEvent (http://localhost:8100/build/vendor.js:13914:155)
at callWithDebugContext (http://localhost:8100/build/vendor.js:15423:42)
at Object.debugHandleEvent [as handleEvent] (http://localhost:8100/build/vendor.js:15010:12)
at dispatchEvent (http://localhost:8100/build/vendor.js:10329:25)
at http://localhost:8100/build/vendor.js:10954:38
at HTMLButtonElement.<anonymous> (http://localhost:8100/build/vendor.js:40350:53)
at t.invokeTask (http://localhost:8100/build/polyfills.js:3:15660)
home.html
<ion-header>
<ion-navbar>
<ion-title>
Stream Media
</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<button (click) = "play()">Play</button>
</ion-content>
home.ts
import { Component } from '@angular/core';
import {StreamingMedia,StreamingVideoOptions} from "@ionic-native/streaming-media/ngx";
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(private streamingMedia:StreamingMedia) {
}
play(){
let options: StreamingVideoOptions = {
successCallback: () => { console.log('Video played') },
errorCallback: (e) => { console.log('Error streaming') },
orientation: 'landscape',
shouldAutoClose: true,
controls: false
};
this.streamingMedia.playVideo('https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_2mb.mp4', options);
}
}
app.module.ts
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 { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import {StreamingMedia} from "@ionic-native/streaming-media/ngx";
@NgModule({
declarations: [
MyApp,
HomePage
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage
],
providers: [
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler},
StreamingMedia
]
})
export class AppModule {}
Thanks.