this.clearAudioTimeInterval = setInterval(timeoutFunction.bind(this),500);
}
}
- else
- {
- this.pause();
- }
}
else
console.log(this.content[this.listIndex].artists[0] + " : " + this.content[this.listIndex].title + " can't play yet, it hasn't loaded");
this.updateMediaName(this.content[this.listIndex].artists[0], this.content[this.listIndex].title, this.content[this.listIndex].coverArt);
$("#audioSrc").attr("src", this.content[this.listIndex].contentURI);
- if (!this.content[this.listIndex].remoteFile)
+ //Only store track to localStorage if it's a local file, and current menu is the Audio menu
+ if (!this.content[this.listIndex].remoteFile && localStorage.prevMenu === "mainMusicButton")
{
localStorage.prevAudioTrack = this.content[this.listIndex].contentURI;
}
this.listIndex = i;
console.log("MediaPlayer: Previous audio found, loading " + this.content[this.listIndex].contentURI);
this.loadPrevAudio = true;
- $("#audioSrc").attr("src", this.content[this.listIndex].contentURI);
- this.playerControls.load();
this.fillMediaList();
+ this.load(i, true);
}
}
}
else
{
console.log("MediaPlayer: No previous audio found, loading first");
- $("#audioSrc").attr("src", this.content[0].contentURI);
- localStorage.prevAudioTrack = this.content[0].contentURI;
- this.playerControls.load();
+ this.load(0, false);
this.updateMediaName(this.content[this.listIndex].artists[0], this.content[this.listIndex].title, this.content[this.listIndex].coverArt);
if (currentMenu === "audio")
else
this.listIndex = 0;
- $("#imagePlayer").css("background", "url(" + this.content[this.listIndex].contentURI + ") no-repeat center");
- $("#imagePlayer").css("background-size", "contain");
+ this.load(this.listIndex);
}
}
else
this.listIndex = this.content.length - 1;
- $("#imagePlayer").css("background", "url(" + this.content[this.listIndex].contentURI + ") no-repeat center");
- $("#imagePlayer").css("background-size", "contain");
+ this.load(this.listIndex);
}
}
{
try
{
- $("#imagePlayer").css("background", "url(" + this.content[0].contentURI + ") no-repeat center");
- $("#imagePlayer").css("background-size", "contain");
+ this.listIndex = 0;
+
+ if (localStorage.prevImage && localStorage.prevImage !== "undefined")
+ {
+ for (var i = 0; i < this.content.length; i++)
+ {
+ if (this.content[i].contentURI === localStorage.prevImage)
+ {
+ console.log("MediaPlayer: using previous image " + localStorage.prevImage);
+ this.listIndex = i;
+ this.fillMediaList();
+ this.load(i);
+ }
+ }
+ }
+ else
+ {
+ console.log("MediaPlayer: using first image " + this.content[this.listIndex].contentURI);
+ this.load(this.listIndex);
+ }
}
catch (err)
ImagePlayer.prototype.load = function(index)
{
this.listIndex = index;
- $("#imagePlayer").css("background", "url(" + this.content[this.listIndex].contentURI + ") no-repeat center");
- $("#imagePlayer").css("background-size", "contain");
+
+ if (!this.content[this.listIndex].remoteFile)
+ {
+ localStorage.prevImage = this.content[this.listIndex].contentURI;
+ }
+ else
+ {
+ localStorage.prevImage = undefined;
+ }
+
+ $("#imagePlayer").css("background", "url(" + this.content[this.listIndex].contentURI + ") no-repeat center");
+ $("#imagePlayer").css("background-size", "contain");
}
ImagePlayer.prototype.makeListItem = function(j, k)
currentMediaList = $("#audioMediaList");
localStorage.prevMenu = "mainMusicButton";
- if (audioPlayer.currentAudioContent)
+ if (audioPlayer.currentAudioContent && audioPlayer.currentAudioContent.contentURI)
{
localStorage.prevAudioTrack = audioPlayer.currentAudioContent.contentURI
localStorage.prevAudioTime = audioPlayer.playerControls.currentTime;
currentPlayer = videoPlayer;
currentMediaList = $("#videoMediaList");
localStorage.prevMenu = "mainVideoButton";
+
+ if (videoPlayer.currentVideoContent && videoPlayer.currentVideoContent.contentURI)
+ {
+ localStorage.prevVideo = videoPlayer.currentVideoContent.contentURI
+ localStorage.prevVideoTime = videoPlayer.playerControls.currentTime;
+ }
+
localStorage.prevAudioTime = undefined;
localStorage.prevAudioTrack = undefined;
function showMainMenu()
{
- console.log("MediaPlayer in showMainMenu");
+ console.log("MediaPlayer in showMainMenu, clearing all localStorage...");
currentMenu = "main";
localStorage.prevMenu = "MAIN";
localStorage.prevAudioTime = undefined;
localStorage.prevAudioTrack = undefined;
localStorage.prevVideo = undefined;
localStorage.prevVideoTime = undefined;
+ localStorage.prevImage = undefined;
+
currentPlayer.pause();
//If the media list is showing, hide it. Remove the mediaListAudioList class if it exists so that it will resize properly
{
this.clearVideoTimeInterval = undefined;
this.loadPrevVideo = false;
+ this.currentVideoContent = undefined;
}
VideoPlayer.prototype.play = function()
this.clearVideoTimeInterval = setInterval(timeoutFunction.bind(this),500);
}
}
- else
- {
- this.pause();
- }
}
VideoPlayer.prototype.pause = function()
{
this.listIndex = index;
this.loadAndPlay = play;
+ this.currentVideoContent = this.content[this.listIndex];
this.playerControls.pause();
$("#videoSrc").attr("src", this.content[this.listIndex].contentURI);
- if (!this.content[this.listIndex].remoteFile)
+ //Only store track to localStorage if it's a local file, and current menu is the Video menu
+ if (!this.content[this.listIndex].remoteFile && localStorage.prevMenu === "mainVideoButton")
{
localStorage.prevVideo = this.content[this.listIndex].contentURI;
}
{
if (this.content[i].contentURI === localStorage.prevVideo)
{
- console.log("MediaPlayer: Previous video found, loading " + this.content[this.listIndex].contentURI);
+ console.log("MediaPlayer: Previous video found, loading " + this.content[i].contentURI);
this.listIndex = i;
this.loadPrevVideo = true;
- $("#videoSrc").attr("src", this.content[this.listIndex].contentURI);
this.fillMediaList();
- this.playerControls.load();
+ this.load(i, true);
}
}
}
else
{
console.log("MediaPlayer: No previous video found, loading first");
- $("#videoSrc").attr("src", this.content[0].contentURI);
- localStorage.prevVideo = this.content[0].contentURI;
- this.playerControls.load();
+ this.load(0,false);
}
}
+* Mon Oct 14 2013 brianjjones <brian.j.jones@intel.com> submit/tizen/20131010.205318@a65dc75
+- Image player will now remember what image it was last on
+
* Tue Oct 08 2013 brianjjones <brian.j.jones@intel.com> accepted/tizen/20131004.164521@81d77fa
- Re-organizing the code so that the players are object based. Adding code to remember
what page you were on as well as the previous media