DISCUSSION FORUM MESSAGE> Forum Message Topic: Re:Re:Re:Re:Re:Re:Re:Re:Re:Re:Re:Codes///// Forum Home Posted by: Hugh Telford Date/Time: 14/01/08 20:09:00 HMV Digital Player var installHelper = new InstallUtils(); var tabControl = new TabControl(); var getStateId; window.onload = function() { // See if a querystring was sent to the window, if so we're on an install callback and need to retrieve // user state setupParameters(); if (window.location.hasParameters) { // Get the users persisted data getStateId = window.setInterval(function(){retrieveUserState()}, 1000); } // Flag that we're loaded document.domain = "hmv.co.uk"; window.isLoaded = true; }; function retrieveUserState() { var storage = $object('state'); if (isSafeObject(storage)) { window.clearInterval(getStateId); storage.retrieveState(window.location.parameters['sessionId']); getStateId = window.setInterval(function(){checkUserState()}, 1000); } } function checkUserState() { var storage = $object('state'); var tracks = storage.get_selectedTracks(); if (isSafeObject(tracks) && tracks.length > 0) { window.clearInterval(getStateId); var parameters = window.location.parameters; switch(parameters['mode']) { case 'player': window.addItemsToPlayer(parameters['sessionId'], tracks); break; case 'downloader': window.downloadSelectedTracks(parameters['sessionId'], tracks, null); break; } } } function keyDown() { var keycode = event.keyCode if (keycode == 116) { var ok = confirm('If you refresh the window, you will lose any tracks in your playlist. Are you sure you want to do this?'); if (!ok) { event.keyCode = 27; return false; } } } document.onkeydown = keyDown; //document.oncontextmenu = new Function("return false"); now playing download manager now playing //common event vars var mediaEnded; var transitioning; var tid; // For passing this window to the parent var idBuffering; // For our buffering event var currentTrackDuration = "00:00"; var trackPositionElement; var trackPositionId = 0; // For updating the current track position \ Timecode var wmp; // Store a reference to windows media player function startIdent() { tid = window.setInterval("passWinToParent()",1000); } function passWinToParent() { try { if(window.opener) { window.opener.resetPlayer(window); clearInterval(tid); } else { clearInterval(tid); } } catch(err1) { // do nothing } } function checkPlayerObject() { var player = $object("mediaPlayer1"); if (typeof(player) == "undefined") { return false; } if (player == null) { return false; } return true; } //add tracks to be sampled to the player function addItemsToPlayer(sessionId, tracks) { //alert(">> addItemsToPlayer, playSample = " + playSample); var player = $object("mediaPlayer1"); if (!isSafeObject(player)) { return false; } window.debug.assert(player, "player can't be null", true); if (tracks == null) { alert("No tracks were selected to be played!"); return; } if (!isSafeObject(wmp)) { wmp = player.get_windowsMediaPlayer(); trackPositionElement = $('trackPosition'); } var isVisible = busyBox.IsVisible(); // If user has tried to add another track before an item has finished processing, we // don't want to attempt to show it again if (!isVisible) { tabControl.toggleTabs('NComingsoon'); busyBox.Show(); window.focus(); } try { player.getUserToken(sessionId, tracks); } catch (err) { busyBox.Hide(); alert('An error occured while retrieving the media, please contact the support department\r\n' + err.message); } } var busyBox = new BusyBox("BusyBoxIFrame", 250, 100, baseUrl + "Scripts/busy/BusyBox.aspx");
50% // var strerror = ""; // store the number of errors in the queue. var max = wmp.error.errorcount // loop through the list of errors. for (var i = 0; i < max; i++) { // display the error description for each item. strerror += "error: " + wmp.error.item(i).errordescription + "\n"; } alert( strerror ); // display the error warning. // clear the error queue to prepare for the next group of errors. wmp.error.clearerrorqueue(); var statusText = ''; if (trackPositionId > 0) { window.clearInterval(trackPositionId); trackPositionId = 0; } switch(NewState) { case 1: statusText = "Stopped"; $('trackPosition').innerHTML = "00:00 / " + _currentTrackDuration; break; case 2: statusText = "Paused"; break; case 3: statusText = "Playing"; if (trackPositionId == 0) { trackPositionId = window.setInterval("updateTrackPosition()", 1000); } _currentTrackDuration = $object("mediaPlayer1").get_trackDuration(); break; case 6: statusText = "Buffering"; break; case 7: statusText = "Waiting"; break; case 8: statusText = "Ended"; break; case 9: statusText = "Loading"; break; case 10: // This is actually 'Ready' status, but is not that useful to the user within the // context of this application statusText = "Preparing..."; break; case 11: statusText = "Reconnecting"; break; default: statusText = "Please Wait"; break; } $('playState').innerHTML = statusText; if (NewState == 8) { mediaEnded = true; } if (NewState == 9) { transitioning = true; } if (NewState == 1) { // If current track has ended and we are preparing a new Media object, then attempt // to move onto the next track in the player if (mediaEnded && transitioning) { if (typeof($object("mediaPlayer1")) == "undefined") { return false; } if ($object("mediaPlayer1") == null) { return false; } $object("mediaPlayer1").nextTrack(); mediaEnded = false; transitioning = false; } } // Test whether buffering has started or stopped. if (true === Start) { // Start the timer. Call the function to update the display every half second. idBuffering = window.setInterval("updateBuffering()", 1000); } else { // Buffering is complete. Stop the timer. window.clearInterval(idBuffering); } function updateBuffering(){ if ($object("mediaPlayer1").get_isPlaying() == false) { // don't want to do anything if the player is paused return; } var bufferingDiv = $('playState'); var progress = wmp.network.bufferingProgress; if ((progress == 0 || progress == 100) && wmp.controls.currentPosition > 0) { bufferingDiv.innerHTML = "Playing"; return; } bufferingDiv.innerHTML = "Buffering" //, " + progress + "%";}function updateTrackPosition(){ trackPositionElement.innerHTML = wmp.controls.currentPositionString + " / " + _currentTrackDuration} function setCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function eraseCookie(name) { setCookie(name,"",-1); } function onAppLoad() { var downloaderAX = $("downloaderAX"); if (isSafeObject(downloaderAX) == false) { return false; } window.debug.assert(downloaderActiveXCodebase, "downloaderActiveXCodebase not defined", true); downloaderAX.codebase = downloaderActiveXCodebase; if (downloaderAX.readyState == 4) { var downloaderAX = $("downloaderAX"); var downloader = $object("downloader"); if (isSafeObject(downloaderAX) == false || isSafeObject(downloader) == false) { return false; } // Load up user settings downloader.set_downloadManager(downloaderAX); downloader.set_downloadLocation(downloaderAX.DownloadLocation); } } function downloadSelectedTracks(sessionId, tracks, mode) { // Check for client installation, this will handle our redirect if // client software not available. if (!installHelper.checkClientInstall()) { var stateObject = $object('state'); stateObject.saveUserState(sessionId, tracks, 'downloader'); return; } tabControl.toggleTabs('NDownloads'); window.focus(); var downloaderAX = $("downloaderAX"); var downloader = $object("downloader"); if (isSafeObject(downloaderAX) == false || isSafeObject(downloader) == false) { return false; } // Shouldn't really be null, expect for possible callback scenario from installer page // in which we can assume they're downloading for the first time if (mode == null) { mode = 'download'; } try { downloader.downloadTracks(sessionId, tracks, mode); } catch(e) { alert(e.description); } } your download location:
Hugh Telford ● 6306d