openvidu-ionic: small refactoring
This commit is contained in:
parent
43a7cf993c
commit
fd0f366e21
@ -22,7 +22,7 @@ export class AppComponent implements OnDestroy {
|
||||
ANDROID_PERMISSIONS = [
|
||||
this.androidPermissions.PERMISSION.CAMERA,
|
||||
this.androidPermissions.PERMISSION.RECORD_AUDIO,
|
||||
this.androidPermissions.PERMISSION.MODIFY_AUDIO_SETTINGS,
|
||||
this.androidPermissions.PERMISSION.MODIFY_AUDIO_SETTINGS
|
||||
];
|
||||
|
||||
// OpenVidu objects
|
||||
@ -59,7 +59,7 @@ export class AppComponent implements OnDestroy {
|
||||
initializeAdapterIosRtc() {
|
||||
console.log('Initializing iosrct');
|
||||
cordova.plugins.iosrtc.registerGlobals();
|
||||
// load adapter.js (vesion 4.0.1)
|
||||
// load adapter.js (version 4.0.1)
|
||||
const script2 = document.createElement('script');
|
||||
script2.type = 'text/javascript';
|
||||
script2.src = 'assets/libs/adapter-4.0.1.js';
|
||||
@ -108,7 +108,7 @@ export class AppComponent implements OnDestroy {
|
||||
// 'getToken' method is simulating what your server-side should do.
|
||||
// 'token' parameter should be retrieved and returned by your own backend
|
||||
this.getToken().then((token) => {
|
||||
// First param is the token got from OpenVidu Server. Second param can be retrieved by every user on event
|
||||
// First param is the token got from OpenVidu Server. Second param will be used by every user on event
|
||||
// 'streamCreated' (property Stream.connection.data), and will be appended to DOM as the user's nickname
|
||||
this.session
|
||||
.connect(token, { clientData: this.myUserName })
|
||||
@ -186,13 +186,13 @@ export class AppComponent implements OnDestroy {
|
||||
.then(() => {
|
||||
this.androidPermissions
|
||||
.checkPermission(this.androidPermissions.PERMISSION.CAMERA)
|
||||
.then((camera) => {
|
||||
.then(camera => {
|
||||
this.androidPermissions
|
||||
.checkPermission(this.androidPermissions.PERMISSION.RECORD_AUDIO)
|
||||
.then((audio) => {
|
||||
.then(audio => {
|
||||
this.androidPermissions
|
||||
.checkPermission(this.androidPermissions.PERMISSION.MODIFY_AUDIO_SETTINGS)
|
||||
.then((modifyAudio) => {
|
||||
.then(modifyAudio => {
|
||||
if (camera.hasPermission && audio.hasPermission && modifyAudio.hasPermission) {
|
||||
resolve();
|
||||
} else {
|
||||
@ -212,7 +212,7 @@ export class AppComponent implements OnDestroy {
|
||||
);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch(err => {
|
||||
console.error(
|
||||
'Checking permission ' +
|
||||
this.androidPermissions.PERMISSION.MODIFY_AUDIO_SETTINGS +
|
||||
@ -221,19 +221,19 @@ export class AppComponent implements OnDestroy {
|
||||
reject(err);
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch(err => {
|
||||
console.error(
|
||||
'Checking permission ' + this.androidPermissions.PERMISSION.RECORD_AUDIO + ' failed',
|
||||
);
|
||||
reject(err);
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch(err => {
|
||||
console.error('Checking permission ' + this.androidPermissions.PERMISSION.CAMERA + ' failed');
|
||||
reject(err);
|
||||
});
|
||||
})
|
||||
.catch((err) => console.error('Error requesting permissions: ', err));
|
||||
.catch(err => console.error('Error requesting permissions: ', err));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@ -20,8 +20,8 @@ import { UserVideoComponent } from './user-video.component';
|
||||
StatusBar,
|
||||
SplashScreen,
|
||||
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
|
||||
AndroidPermissions,
|
||||
AndroidPermissions
|
||||
],
|
||||
bootstrap: [AppComponent],
|
||||
bootstrap: [AppComponent]
|
||||
})
|
||||
export class AppModule { }
|
||||
|
||||
@ -5,14 +5,7 @@ declare var cordova;
|
||||
|
||||
@Component({
|
||||
selector: 'ov-video',
|
||||
template: '<video #videoElement></video>',
|
||||
styles: [
|
||||
`
|
||||
video {
|
||||
width: inherit;
|
||||
}
|
||||
`
|
||||
]
|
||||
template: '<video #videoElement></video>'
|
||||
})
|
||||
export class OpenViduVideoComponent implements AfterViewInit, OnDestroy {
|
||||
|
||||
@ -23,7 +16,7 @@ export class OpenViduVideoComponent implements AfterViewInit, OnDestroy {
|
||||
|
||||
constructor(private platform: Platform) {}
|
||||
|
||||
ngAfterViewInit() {window.addEventListener
|
||||
ngAfterViewInit() {
|
||||
if (this.isIos() && this._streamManager.remote) {
|
||||
this.rotationFunction = () => {
|
||||
// Give the remote video some time to update its dimensions when rotating the device
|
||||
@ -48,8 +41,7 @@ export class OpenViduVideoComponent implements AfterViewInit, OnDestroy {
|
||||
this._streamManager = streamManager;
|
||||
if (this.isIos()) {
|
||||
this._streamManager.on('streamPropertyChanged', event => {
|
||||
let e: StreamPropertyChangedEvent = <StreamPropertyChangedEvent>event;
|
||||
if (e.changedProperty === 'videoDimensions') {
|
||||
if ((<StreamPropertyChangedEvent>event).changedProperty === 'videoDimensions') {
|
||||
this.applyIosIonicVideoAttributes();
|
||||
cordova.plugins.iosrtc.refreshVideos();
|
||||
}
|
||||
@ -67,7 +59,7 @@ export class OpenViduVideoComponent implements AfterViewInit, OnDestroy {
|
||||
}
|
||||
|
||||
private applyIosIonicVideoAttributes() {
|
||||
let ratio = this._streamManager.stream.videoDimensions.height / this._streamManager.stream.videoDimensions.width;
|
||||
const ratio = this._streamManager.stream.videoDimensions.height / this._streamManager.stream.videoDimensions.width;
|
||||
this.elementRef.nativeElement.style.width = '100% !important';
|
||||
this.elementRef.nativeElement.style.objectFit = 'fill';
|
||||
this.elementRef.nativeElement.style.zIndex = '-1';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user