Video is playing in another view
HI,
Clicking on view video opening in new window / view.
If I give the hard coded the url of the video to be played coming in same view... if its coming dynamically (basically from global variable), video is playing in new view / window / media player...
Below is the code
var BasicPlayerView = new KONtx.Class({
ClassName: 'BasicPlayerView',
Extends: KONtx.system.FullscreenView,
initView: function() {
KONtx.mediaplayer.initialize();
this.dialogs = {};
this.dialogs.error = new KONtx.dialogs.Alert({
title: $_('video_error_dialog_title'),
message: $_('video_error_dialog_message'),
buttons: [
{ label: $_('dialog_retry_button'), callback: function() {
KONtx.mediaplayer.playlist.start();
} },
{ label: $_('dialog_cancel_button'), callback: function() {
KONtx.application.loadView('view-images');
} },
]
});
},
createView: function() {
this.controls.overlay = new KONtx.control.MediaTransportOverlay().appendTo(this);
},
focusView: function() {
this.controls.overlay.focus();
},
updateView: function() {
this._registerHandlers();
this._resetViewport();
this._handlePlaylistUpdate();
},
hideView: function() {
this._unregisterHandlers();
},
_handlePlaylistUpdate: function() {
// Otherwise, we need to start this new playlist
this._startPlaylist();
},
_startPlaylist: function() {
this.controls.overlay.resetState();
KONtx.mediaplayer.playlist.set(this._createPlaylist());
KONtx.mediaplayer.setConnectionBandwidth(KONtx.messages.fetch("bandwidth") || 1);
KONtx.mediaplayer.playlist.start();
},
_createPlaylist: function() {
var playlist = new KONtx.media.Playlist();
playlist.addEntry(new KONtx.media.PlaylistEntry({
streams: [
{url: selectedVideo}, // selectedVideo is the global variable, assigning the video url in previous view
]
}));
return playlist;
},
_resetViewport: function() {
var bounds = KONtx.mediaplayer.getDefaultViewportBounds();
KONtx.mediaplayer.setViewportBounds(bounds);
},
_registerHandlers: function() {
if(this._boundPlayerHandler) {
this._unregisterHandlers();
}
this._boundPlayerHandler = this._playerDispatcher.subscribeTo(KONtx.mediaplayer, ['onStateChange', 'onPlaylistEnd', 'onStreamLoadError'], this);
},
_unregisterHandlers: function() {
if(this._boundPlayerHandler) {
this._boundPlayerHandler.unsubscribeFrom(KONtx.mediaplayer, ['onStateChange', 'onPlaylistEnd', 'onStreamLoadError']);
this._boundPlayerHandler = null;
}
},
_playerDispatcher: function(event) {
switch(event.type) {
case 'onStateChange':
if(event.payload.newState == KONtx.mediaplayer.constants.states.STOP) {
//KONtx.application.previousView();
KONtx.application.loadView('view-images');
}
if(event.payload.newState == KONtx.mediaplayer.constants.states.ERROR || event.payload.newState == KONtx.mediaplayer.constants.states.UNKNOWN) {
this.dialogs.error.show();
}
break;
case 'onPlaylistEnd':
//KONtx.application.previousView();
KONtx.application.loadView('view-images');
break;
case 'onStreamLoadError':
this.dialogs.error.show();
break;
default:
break;
}
}
});
Regards
Swarupa
by
3 Replies