1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

log request headers

This commit is contained in:
Luke Pulverenti 2014-08-17 14:12:17 -04:00
parent 8b032714a9
commit 35cef416a9
3 changed files with 13 additions and 77 deletions

View file

@ -63,12 +63,6 @@
this.currentMediaTime = 0; this.currentMediaTime = 0;
// @type {Number} A number for current media duration // @type {Number} A number for current media duration
this.currentMediaDuration = -1; this.currentMediaDuration = -1;
// @type {Timer} A timer for tracking progress of media
this.timer = null;
// @type {Boolean} A boolean to stop timer update of progress when triggered by media status event
this.progressFlag = true;
// @type {Number} A number in milliseconds for minimal progress update
this.timerStep = 1000;
this.hasReceivers = false; this.hasReceivers = false;
@ -85,7 +79,6 @@
// bind once - commit 2ebffc2271da0bc5e8b13821586aee2a2e3c7753 // bind once - commit 2ebffc2271da0bc5e8b13821586aee2a2e3c7753
this.errorHandler = this.onError.bind(this); this.errorHandler = this.onError.bind(this);
this.incrementMediaTimeHandler = this.incrementMediaTime.bind(this);
this.mediaStatusUpdateHandler = this.onMediaStatusUpdate.bind(this); this.mediaStatusUpdateHandler = this.onMediaStatusUpdate.bind(this);
this.initializeCastPlayer(); this.initializeCastPlayer();
@ -111,9 +104,10 @@
// v1 Id AE4DA10A // v1 Id AE4DA10A
// v2 Id 472F0435 // v2 Id 472F0435
// v3 Id 69C59853
// default receiver chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID // default receiver chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID
var applicationID = "69C59853"; var applicationID = "472F0435";
// request session // request session
var sessionRequest = new chrome.cast.SessionRequest(applicationID); var sessionRequest = new chrome.cast.SessionRequest(applicationID);
@ -205,7 +199,6 @@
this.deviceState = DEVICE_STATE.IDLE; this.deviceState = DEVICE_STATE.IDLE;
this.castPlayerState = PLAYER_STATE.IDLE; this.castPlayerState = PLAYER_STATE.IDLE;
this.currentMediaSession = null; this.currentMediaSession = null;
clearInterval(this.timer);
MediaController.removeActivePlayer(PlayerName); MediaController.removeActivePlayer(PlayerName);
} }
@ -219,9 +212,6 @@
CastPlayer.prototype.launchApp = function () { CastPlayer.prototype.launchApp = function () {
console.log("chromecast launching app..."); console.log("chromecast launching app...");
chrome.cast.requestSession(this.onRequestSessionSuccess.bind(this), this.onLaunchError.bind(this)); chrome.cast.requestSession(this.onRequestSessionSuccess.bind(this), this.onLaunchError.bind(this));
if (this.timer) {
clearInterval(this.timer);
}
}; };
/** /**
@ -269,7 +259,6 @@
this.deviceState = DEVICE_STATE.IDLE; this.deviceState = DEVICE_STATE.IDLE;
this.castPlayerState = PLAYER_STATE.IDLE; this.castPlayerState = PLAYER_STATE.IDLE;
this.currentMediaSession = null; this.currentMediaSession = null;
clearInterval(this.timer);
}; };
/** /**
@ -315,19 +304,12 @@
if (how == 'loadMedia') { if (how == 'loadMedia') {
this.castPlayerState = PLAYER_STATE.PLAYING; this.castPlayerState = PLAYER_STATE.PLAYING;
clearInterval(this.timer);
this.startProgressTimer();
} }
if (how == 'activeSession') { if (how == 'activeSession') {
this.castPlayerState = mediaSession.playerState; this.castPlayerState = mediaSession.playerState;
} }
if (this.castPlayerState == PLAYER_STATE.PLAYING) {
// start progress timer
this.startProgressTimer();
}
this.currentMediaSession.addUpdateListener(this.mediaStatusUpdateHandler); this.currentMediaSession.addUpdateListener(this.mediaStatusUpdateHandler);
this.currentMediaDuration = mediaSession.media.duration * 10000000; this.currentMediaDuration = mediaSession.media.duration * 10000000;
}; };
@ -345,29 +327,12 @@
* @param {!Boolean} e true/false * @param {!Boolean} e true/false
*/ */
CastPlayer.prototype.onMediaStatusUpdate = function (e) { CastPlayer.prototype.onMediaStatusUpdate = function (e) {
if (e == false) { if (e == false) {
this.currentMediaTime = 0; this.currentMediaTime = 0;
this.castPlayerState = PLAYER_STATE.IDLE; this.castPlayerState = PLAYER_STATE.IDLE;
} }
console.log("chromecast updating media"); console.log("chromecast updating media");
this.updateProgressBarByTimer();
};
/**
* Helper function
* Increment media current position by 1 second
*/
CastPlayer.prototype.incrementMediaTime = function () {
if (this.castPlayerState == PLAYER_STATE.PLAYING) {
if (this.currentMediaTime < this.currentMediaDuration) {
this.currentMediaTime += 1;
this.updateProgressBarByTimer();
}
else {
this.currentMediaTime = 0;
clearInterval(this.timer);
}
}
}; };
/** /**
@ -387,16 +352,6 @@
this.errorHandler); this.errorHandler);
this.currentMediaSession.addUpdateListener(this.mediaStatusUpdateHandler); this.currentMediaSession.addUpdateListener(this.mediaStatusUpdateHandler);
this.castPlayerState = PLAYER_STATE.PLAYING; this.castPlayerState = PLAYER_STATE.PLAYING;
// start progress timer
clearInterval(this.timer);
this.startProgressTimer();
break;
case PLAYER_STATE.IDLE:
case PLAYER_STATE.LOADING:
case PLAYER_STATE.STOPPED:
this.loadMedia();
this.currentMediaSession.addUpdateListener(this.mediaStatusUpdateHandler);
this.castPlayerState = PLAYER_STATE.PLAYING;
break; break;
default: default:
break; break;
@ -417,7 +372,6 @@
this.currentMediaSession.pause(null, this.currentMediaSession.pause(null,
this.mediaCommandSuccessCallback.bind(this, "paused " + this.currentMediaSession.sessionId), this.mediaCommandSuccessCallback.bind(this, "paused " + this.currentMediaSession.sessionId),
this.errorHandler); this.errorHandler);
clearInterval(this.timer);
} }
}; };
@ -434,7 +388,6 @@
this.mediaCommandSuccessCallback.bind(this, "stopped " + this.currentMediaSession.sessionId), this.mediaCommandSuccessCallback.bind(this, "stopped " + this.currentMediaSession.sessionId),
this.errorHandler); this.errorHandler);
this.castPlayerState = PLAYER_STATE.STOPPED; this.castPlayerState = PLAYER_STATE.STOPPED;
clearInterval(this.timer);
}; };
/** /**
@ -538,7 +491,7 @@
console.log('CastPlayer.updateProgressBar'); console.log('CastPlayer.updateProgressBar');
if (e.idleReason == 'FINISHED' && e.playerState == 'IDLE') { if (e.idleReason == 'FINISHED' && e.playerState == 'IDLE') {
clearInterval(this.timer);
this.castPlayerState = PLAYER_STATE.STOPPED; this.castPlayerState = PLAYER_STATE.STOPPED;
if (e.idleReason == 'FINISHED') { if (e.idleReason == 'FINISHED') {
$(this).trigger("/playback/complete", e); $(this).trigger("/playback/complete", e);
@ -546,19 +499,9 @@
} }
else { else {
var p = Number(e.currentTime / this.currentMediaSession.media.duration + 1).toFixed(3); var p = Number(e.currentTime / this.currentMediaSession.media.duration + 1).toFixed(3);
this.progressFlag = false;
setTimeout(this.setProgressFlag.bind(this), 1000); // don't update progress in 1 second
} }
}; };
/**
* Set progressFlag with a timeout of 1 second to avoid UI update
* until a media status update from receiver
*/
CastPlayer.prototype.setProgressFlag = function () {
this.progressFlag = true;
};
/** /**
* Update progress bar based on timer * Update progress bar based on timer
*/ */
@ -589,26 +532,13 @@
} }
if (pp > 100 || this.castPlayerState == PLAYER_STATE.IDLE) { if (pp > 100 || this.castPlayerState == PLAYER_STATE.IDLE) {
clearInterval(this.timer);
this.deviceState = DEVICE_STATE.IDLE; this.deviceState = DEVICE_STATE.IDLE;
this.castPlayerState = PLAYER_STATE.IDLE; this.castPlayerState = PLAYER_STATE.IDLE;
$(this).trigger("/playback/complete", true); $(this).trigger("/playback/complete", true);
} }
}; };
/**
* @param {function} A callback function for the fucntion to start timer
*/
CastPlayer.prototype.startProgressTimer = function () {
if (this.timer) {
clearInterval(this.timer);
this.timer = null;
}
// start progress timer
this.timer = setInterval(this.incrementMediaTimeHandler, this.timerStep);
};
// Create Cast Player // Create Cast Player
var castPlayer = new CastPlayer(); var castPlayer = new CastPlayer();

View file

@ -728,7 +728,8 @@
items: result.Items, items: result.Items,
smallIcon: true, smallIcon: true,
showIndex: true, showIndex: true,
index: 'disc' index: 'disc',
showIndexNumber: true
})).trigger('create').createCardMenus(); })).trigger('create').createCardMenus();

View file

@ -768,7 +768,12 @@
textlines.push(item.AlbumArtist || 'Unknown Artist'); textlines.push(item.AlbumArtist || 'Unknown Artist');
} }
textlines.push(LibraryBrowser.getPosterViewDisplayName(item)); var displayName = LibraryBrowser.getPosterViewDisplayName(item);
if (options.showIndexNumber && item.IndexNumber != null) {
displayName = item.IndexNumber + ". " + displayName;
}
textlines.push(displayName);
if (item.Type == 'Audio') { if (item.Type == 'Audio') {
textlines.push(item.Artists.join(', ') || 'Unknown Artist'); textlines.push(item.Artists.join(', ') || 'Unknown Artist');