diff -r 79c49924ae23 -r af3740e3753f mpviewplugins/mpdetailsviewplugin/resources/musiccontext.js --- a/mpviewplugins/mpdetailsviewplugin/resources/musiccontext.js Tue Jul 06 14:13:36 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,165 +0,0 @@ -//Logging for QT - -// Override the default alert function. -// TODO remove this when alert in platform is working? -alert = function(str) { - console.log(str); - window.context.owner().errorHandler("Alert", str); -} - -function logme(str){ - console.log(str); - if(window['context'] && context['owner']){ - context.owner().debugJs('debugJs: ' + str); - } -} - -function traceme(){ - var cf = arguments.callee.caller; - logme('-------------- Start traceme ' + new Date().toLocaleTimeString() + ' --------------'); - var arr = new Array(); - while (cf) { - var fn = cf.toString(); - fn = fn.substr(0,fn.indexOf('{')); - arr.push(fn); - cf = cf.caller; - } - //arr.reverse(); - for(i=0;i<=arr.length -1;i++){ - logme(arr[i]); - } - logme('-------------- End traceme --------------'); -} - - -window["music"] = window["music"] || -{}; - -(function(){ - var musicContext = null; - var publishingPlayer = null; - - music.getPostContent = function(){ - traceme(); - return { - reservedLength : window.context.objectReservedLength(), - type : window.context.objectType(), - content : window.context.objectContent() - }; - } - - /** - * Call this for player to show UI and initialize connection to SNC - */ - music.initPlayer = function() - { - traceme(); - // Initialize player - publishingPlayer = new ovi.player.publish.Player({ - locale : window.context.language(), - credentials : { - type : "", - sso_base_url : "", - token : _getNoa() - } - }); - - // Show UI - publishingPlayer.create(null, function(status, data){ - traceme(); - if (status != publishingPlayer.status.updateservices_ok && status != publishingPlayer.status.show_ok) { - // Delegate errors to native side - window.context.owner().errorHandler(status, data.message); - } - }); - - } - - /** - * Call this for player to update context area (the song UI). - */ - music.updateContextArea = function() { - // Update artist and title metadata. - traceme(); - publishingPlayer.setContextObject(_getMusicContext()); - if(window['context'] && context['owner']){ - context.owner().showWindow(); - } -} - - /** - * Call this function to update metadata (called when music player has retrieved the link) - */ - music.updateMetadata = function() { - // Update url at bottom of comment field. - traceme(); - musicContext.updateObject(music.getPostContent()); - } - - /** - * Call this function to release all resources from player. - */ - music.teardown = function() { - traceme(); - publishingPlayer.cancel(); - } - - // Private functions, read data from native side.. - function _playerReady() { - traceme(); - return typeof ovi != "undefined" && - typeof ovi.player != "undefined" && - typeof ovi.player.publish != "undefinded"; - } - - - function _getMusicContext() { - traceme(); - musicContext = new ovi.player.contextobject.Player(); - - var attachment = music.getPostContent(); - - logme('music._getMusicContext() | attachment'); - - logme('music._getMusicContext() | musicContext.create'); - - var sharePlayerArtImage = ""; - var sharePlayerArtBase64 = window.context.albumArtBase64(); - if ( sharePlayerArtBase64.length > 0 ) { - // TODO: this is temporary solution until base64 defect in QT is fixed. - sharePlayerArtImage = "
"
- + ""
- + " " + window.context.title() + " "
- + "" + window.context.artist() + " "
- + ""
- + " |