media player sample

Julian Bankston28 May 2011 8:53 AM
Hello. i have been working on the basic media sample and i am receiving this error when trying to play a playlist.

WM 00:02:08:876: [T:14590] no listeners for event
WM 00:02:08:876: [T:14590] [KONtx/UARLIVE] {ControlVideoTransportOverlayButton-24} :: focus
WE 00:02:08:877: [T:14590] !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
WE 00:02:08:877: [T:14590] ERROR!ERROR!ERROR!ERROR!ERROR!
WE 00:02:08:877: [T:14590] !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
WE 00:02:08:877: [T:14590] UARLIVE [tv.mave.widgets.uarlive]
WE 00:02:08:877: [T:14590] TypeError: json is undefined (basicplayer.js: Line 77)
WE 00:02:08:877: [T:14590] !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
WM 00:02:08:879: [T:14590] [KONtx/UARLIVE] {HostEventManager} :: Got HostEvent: onUnselect
WM 00:02:08:879: [T:14590] [KONtx/UARLIVE] {SampleSidebarView-14} :: _onUnselectView
WM 00:02:08:880: [T:14590] [KONtx/UARLIVE] {HostEventManager} :: Got HostEvent: onSelect
WM 00:02:08:881: [T:14590] [KONtx/UARLIVE] {BasicPlayerView-20} :: _onSelectView
WM 00:02:08:881: [T:14590] calling window.navigate()
WM 00:02:08:881: [T:14590] gainfocus: view-Player

here is the section in question. basicplayer.js: Line 77

_createPlaylist: function(playlistID) {
var playlist = new KONtx.media.Playlist();
playlist.PlaylistID = playlistID;

var json = KONtx.messages.fetch("playlist." + playlistID);
for each(var entry in json.entries) {
var playlistEntry = new KONtx.media.PlaylistEntry(entry);
playlistEntry.entryID = entry.entryID;
playlist.addEntry(playlistEntry);
}

return playlist;
},

any help is appreciated. thanks.
Julian Bankston2 Jun 2011 7:45 AM
here is my basicplayer.js

CODE
/**
* @author jstone
*/

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.previousView();
} },
]
});
},

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(this.persist.PlaylistID);
},

hideView: function() {
this._unregisterHandlers();
},

_handlePlaylistUpdate: function(playlistID) {
if(KONtx.mediaplayer.isPlaylistEntryActive) {
if(!playlistID) {
// we have no new playlist we've been asked to play, so keep playing what we already are playing
return;
}
if(playlistID == KONtx.mediaplayer.playlist.get().PlaylistID) {
// we have been asked to play the same playlist we are already playing, so just keeping playing it
return;
}
}

// Otherwise, we need to start this new playlist
this._startPlaylist(playlistID);
},

_startPlaylist: function(playlistID) {
this.controls.overlay.resetState();

KONtx.mediaplayer.playlist.set(this._createPlaylist(playlistID));

KONtx.mediaplayer.setConnectionBandwidth(KONtx.messages.fetch("bandwidth") || 1);
KONtx.mediaplayer.playlist.start();
},

_createPlaylist: function(playlistID) {
var playlist = new KONtx.media.Playlist();
playlist.PlaylistID = playlistID;

var json = KONtx.messages.fetch("playlist." + playlistID);
for each(var entry in json.entries) {
var playlistEntry = new KONtx.media.PlaylistEntry(entry);
playlistEntry.entryID = entry.entryID;
playlist.addEntry(playlistEntry);
}

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();
}
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();
break;
case 'onStreamLoadError':
this.dialogs.error.show();
break;
default:
break;
}
}
});
julian22 Aug 2011 8:35 AM
thanks. i found the issue. <br><br><div class="quote"><div class="quotetop">QUOTE<cite>(Julian Bankston @ 2 Jun 2011 7:45 AM)</cite></div><blockquote class="quotemain">here is my basicplayer.js<br><br><!--c1--><div class="code generic"><div class="codetop">CODE</div><pre class="codemain"><code><!--ec1-->/**<br> * @author jstone<br> */<br><br>var BasicPlayerView = new KONtx.Class({<br> ClassName: &#39;BasicPlayerView&#39;,<br> <br> Extends: KONtx.system.FullscreenView,<br> <br> initView: function() {<br> KONtx.mediaplayer.initialize();<br> <br> this.dialogs = {};<br> <br> this.dialogs.error = new KONtx.dialogs.Alert({<br> title: $_(&#39;video_error_dialog_title&#39;),<br> message: $_(&#39;video_error_dialog_message&#39;),<br> buttons: [<br> { label: $_(&#39;dialog_retry_button&#39;), callback: function() {<br> KONtx.mediaplayer.playlist.start();<br> } },<br> { label: $_(&#39;dialog_cancel_button&#39;), callback: function() {<br> KONtx.application.previousView();<br> } },<br> ] <br> });<br> },<br> <br> createView: function() {<br> this.controls.overlay = new KONtx.control.MediaTransportOverlay().appendTo(this);<br> },<br> <br> focusView: function() {<br> this.controls.overlay.focus();<br> },<br> <br> updateView: function() { <br> this._registerHandlers();<br> this._resetViewport();<br> this._handlePlaylistUpdate(this.persist.PlaylistID);<br> },<br> <br> hideView: function() {<br> this._unregisterHandlers();<br> },<br> <br> _handlePlaylistUpdate: function(playlistID) {<br> if(KONtx.mediaplayer.isPlaylistEntryActive) {<br> if(!playlistID) {<br> // we have no new playlist we&#39;ve been asked to play, so keep playing what we already are playing<br> return;<br> }<br> if(playlistID == KONtx.mediaplayer.playlist.get().PlaylistID) {<br> // we have been asked to play the same playlist we are already playing, so just keeping playing it<br> return;<br> }<br> }<br> <br> // Otherwise, we need to start this new playlist<br> this._startPlaylist(playlistID);<br> },<br> <br> _startPlaylist: function(playlistID) {<br> this.controls.overlay.resetState();<br> <br> KONtx.mediaplayer.playlist.set(this._createPlaylist(playlistID));<br> <br> KONtx.mediaplayer.setConnectionBandwidth(KONtx.messages.fetch(&quot;bandwidth&quot;) || 1);<br> KONtx.mediaplayer.playlist.start();<br> },<br> <br> _createPlaylist: function(playlistID) {<br> var playlist = new KONtx.media.Playlist(); <br> playlist.PlaylistID = playlistID;<br> <br> var json = KONtx.messages.fetch(&quot;playlist.&quot; + playlistID);<br> for each(var entry in json.entries) {<br> var playlistEntry = new KONtx.media.PlaylistEntry(entry);<br> playlistEntry.entryID = entry.entryID; <br> playlist.addEntry(playlistEntry);<br> }<br> <br> return playlist;<br> },<br> <br> _resetViewport: function() {<br> var bounds = KONtx.mediaplayer.getDefaultViewportBounds();<br> KONtx.mediaplayer.setViewportBounds(bounds);<br> },<br> <br> _registerHandlers: function() {<br> if(this._boundPlayerHandler) {<br> this._unregisterHandlers();<br> }<br> this._boundPlayerHandler = this._playerDispatcher.subscribeTo(KONtx.mediaplayer, [&#39;onStateChange&#39;, &#39;onPlaylistEnd&#39;, &#39;onStreamLoadError&#39;], this);<br> },<br> <br> _unregisterHandlers: function() {<br> if(this._boundPlayerHandler) {<br> this._boundPlayerHandler.unsubscribeFrom(KONtx.mediaplayer, [&#39;onStateChange&#39;, &#39;onPlaylistEnd&#39;, &#39;onStreamLoadError&#39;]);<br> this._boundPlayerHandler = null;<br> }<br> },<br> <br> _playerDispatcher: function(event) {<br> switch(event.type) {<br> case &#39;onStateChange&#39;:<br> if(event.payload.newState == KONtx.mediaplayer.constants.states.STOP) {<br> KONtx.application.previousView();<br> }<br> if(event.payload.newState == KONtx.mediaplayer.constants.states.ERROR || event.payload.newState == KONtx.mediaplayer.constants.states.UNKNOWN) {<br> this.dialogs.error.show();<br> }<br> break;<br> case &#39;onPlaylistEnd&#39;:<br> KONtx.application.previousView(); <br> break;<br> case &#39;onStreamLoadError&#39;:<br> this.dialogs.error.show();<br> break;<br> default:<br> break;<br> }<br> }<br>});<!--c2--></code></pre></div><!--ec2--></blockquote></div>