That's actually much easier and can be illustrated in a small amount of code:
CODE
this.player = new KONtx.videoplayer({
playlist: [ { url: "http://myvideo.url" } ],
repeatAll: true,
events: {
onStateChange: function(event) {
if(event.payload.newState == event.payload.videoplayer.states.STOP) {
KONtx.application.previousView();
}
},
onPlaylistEnd: function(event) {
KONtx.application.previousView();
},
onVideoLoadError: function(event) {
_showErrorDialog();
}
}
});
Please note that the code provided in this forum is considered “Sample Code” under the Developer Terms of Use (with specific reference to Section 2.1(iii)).
Though this code works fine in the simulator, it doesn't seem to work on a production TV. Can you verify this?
We have a Samsung LED TV Series 7 and I used your alpha release tool to deploy a test widget on the TV. The error dialog fires during updateView and shows the exception "TypeError: this.player has no properties".
Framework: 1.1
WDK: 0.9.5-33
Resolution: 540
Our PlayerView.js (below) is based on your code above and YahooVideoTV.widget's VideoFullscreenPlayerView.js
CODE
var PlayerView = new KONtx.Class({
ClassName: 'MyPlayerView',
Extends: KONtx.system.FullscreenView,
createView: function(){
this._debugMsg("createView");
var self = this;
this.controls.overlay = new KONtx.control.VideoTransportOverlay().appendTo(this);
this.player = new KONtx.videoplayer({
playlist: [{
url: "http://cosmos.bcst.yahoo.com/getPlaylist.php?node_id=12553529&bitrate=1000&tech=wmp"
}],
events: {
onStateChange: function(event){
if (event.payload.newState == event.payload.videoplayer.states.STOP) {
self._debugMsg("STOP");
self._switchBackToSidebar();
}
},
onPlaylistEnd: function(event){
self._debugMsg("PLAYLIST END");
self._switchBackToSidebar();
},
onVideoLoadError: function(event){
self._debugMsg("ERROR");
self._showErrorDialog("onVideoLoadError: " + event);
}
}
});
this.player.attachAccessory(this.controls.overlay);
},
focusView: function() {
this.controls.overlay.focus();
},
hideView: function() {
this._unbindHandler();
},
updateView: function(){
this._debugMsg("updateView");
this._boundHandler = this._backHandler.subscribeTo(KONtx.application, ['onActivateBackButton','onViewChangeInitiated'], this);
this.controls.overlay.resetState();
try {
this.player.startPlaylist();
}
catch (e) {
this._debugMsg("Caught an exception, so going back to sidebar");
this._showErrorDialog("updateView exception: " + e);
}
},
_backHandler: function(event) {
event.preventDefault();
this._stopVideoConfirmationDialog();
},
_debugMsg: function(msg) {
log("--------------------------------");
log(msg);
log("--------------------------------");
},
_showErrorDialog: function(msg) {
var self = this;
new KONtx.dialogs.Alert({
title: $_('video_error_dialog_title'),
message: msg,
buttons: [
{ label: $_('dialog_ok_button'), callback: function() {
self._switchBackToSidebar();
} }
]
}).show();
},
_stopVideoConfirmationDialog: function() {
log("popping stop confirmation dialog");
var stopCallback = (function() { this.player.stop(); }).bindTo(this);
new KONtx.dialogs.Alert({
title: $_('stop_video_dialog_title'),
message: $_('stop_video_dialog_message'),
buttons: [
{ label: $_('continue_playing') },
{ label: $_('stop_playing'), callback: stopCallback }
]
}).show();
},
_switchBackToSidebar: function() {
this._unbindHandler();
KONtx.application.previousView();
},
_unbindHandler: function() {
if(this._boundHandler) {
this._boundHandler.unsubscribeFrom(KONtx.application, ['onActivateBackButton','onViewChangeInitiated']);
this._boundHandler = null;
}
}
});