mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Chromecast update
This commit is contained in:
parent
66a2e3ce93
commit
0eb38f9822
1 changed files with 412 additions and 402 deletions
|
@ -27,7 +27,9 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
var PlayerName = 'Chromecast';
|
var PlayerName = 'Chromecast';
|
||||||
|
var cPlayer = {
|
||||||
|
deviceState: DEVICE_STATE.IDLE
|
||||||
|
};
|
||||||
var CastPlayer = function () {
|
var CastPlayer = function () {
|
||||||
|
|
||||||
/* device variables */
|
/* device variables */
|
||||||
|
@ -105,7 +107,9 @@
|
||||||
|
|
||||||
// v1 Id AE4DA10A
|
// v1 Id AE4DA10A
|
||||||
// v2 Id 472F0435
|
// v2 Id 472F0435
|
||||||
var applicationID = '472F0435';
|
// default receiver chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID
|
||||||
|
|
||||||
|
var applicationID = chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID;
|
||||||
|
|
||||||
// request session
|
// request session
|
||||||
var sessionRequest = new chrome.cast.SessionRequest(applicationID);
|
var sessionRequest = new chrome.cast.SessionRequest(applicationID);
|
||||||
|
@ -252,40 +256,45 @@
|
||||||
* @param {Number} mediaIndex An index number to indicate current media content
|
* @param {Number} mediaIndex An index number to indicate current media content
|
||||||
*/
|
*/
|
||||||
CastPlayer.prototype.loadMedia = function (userId, options, command) {
|
CastPlayer.prototype.loadMedia = function (userId, options, command) {
|
||||||
|
var cPlayer = this;
|
||||||
if (!this.session) {
|
if (!this.session) {
|
||||||
console.log("no session");
|
console.log("no session");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
startTimeTicks = 0; // TODO: update this
|
||||||
|
this.currentMediaOffset = startTimeTicks || 0;
|
||||||
|
|
||||||
//this.currentMediaOffset = startTimeTicks || 0;
|
ApiClient.getItem(userId, options.ids[0]).done(function (item) {
|
||||||
|
var maxBitrate = 12000000;
|
||||||
|
var mediaInfo = getMediaSourceInfo(userId, item, maxBitrate, item.MediaSources[0].Id, 0, 0);
|
||||||
|
|
||||||
//var maxBitrate = 12000000;
|
var streamUrl = getStreamUrl(item, mediaInfo, startTimeTicks, maxBitrate);
|
||||||
//var mediaInfo = getMediaSourceInfo(user, item, maxBitrate, mediaSourceId, audioStreamIndex, subtitleStreamIndex);
|
|
||||||
|
|
||||||
//var streamUrl = getStreamUrl(item, mediaInfo, startTimeTicks, maxBitrate);
|
var castMediaInfo = new chrome.cast.media.MediaInfo(streamUrl);
|
||||||
|
|
||||||
//var castMediaInfo = new chrome.cast.media.MediaInfo(streamUrl);
|
castMediaInfo.customData = getCustomData(item, mediaInfo.mediaSource.Id, startTimeTicks);
|
||||||
|
castMediaInfo.metadata = getMetadata(item);
|
||||||
|
|
||||||
//castMediaInfo.customData = getCustomData(item, mediaInfo.mediaSource.Id, startTimeTicks);
|
if (mediaInfo.streamContainer == 'm3u8') {
|
||||||
//castMediaInfo.metadata = getMetadata(item);
|
castMediaInfo.contentType = 'application/x-mpegURL';
|
||||||
|
} else {
|
||||||
|
castMediaInfo.contentType = item.MediaType.toLowerCase() + '/' + mediaInfo.streamContainer.toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
//if (mediaInfo.streamContainer == 'm3u8') {
|
castMediaInfo.streamType = mediaInfo.isStatic ? chrome.cast.media.StreamType.BUFFERED : chrome.cast.media.StreamType.LIVE;
|
||||||
// castMediaInfo.contentType = 'application/x-mpegURL';
|
|
||||||
//} else {
|
|
||||||
// castMediaInfo.contentType = item.MediaType.toLowerCase() + '/' + mediaInfo.streamContainer.toLowerCase();
|
|
||||||
//}
|
|
||||||
|
|
||||||
//castMediaInfo.streamType = mediaInfo.isStatic ? chrome.cast.media.StreamType.BUFFERED : chrome.cast.media.StreamType.LIVE;
|
var request = new chrome.cast.media.LoadRequest(castMediaInfo);
|
||||||
|
request.autoplay = true;
|
||||||
|
request.currentTime = startTimeTicks ? startTimeTicks / 10000000 : 0;
|
||||||
|
|
||||||
|
|
||||||
|
cPlayer.castPlayerState = PLAYER_STATE.LOADING;
|
||||||
|
cPlayer.session.loadMedia(request,
|
||||||
|
cPlayer.onMediaDiscovered.bind(cPlayer, 'loadMedia'),
|
||||||
|
cPlayer.onLoadMediaError.bind(cPlayer));
|
||||||
|
});
|
||||||
|
|
||||||
//var request = new chrome.cast.media.LoadRequest(castMediaInfo);
|
|
||||||
//request.autoplay = true;
|
|
||||||
//request.currentTime = startTimeTicks ? startTimeTicks / 10000000 : 0;
|
|
||||||
|
|
||||||
//this.castPlayerState = PLAYER_STATE.LOADING;
|
|
||||||
//this.session.loadMedia(request,
|
|
||||||
// this.onMediaDiscovered.bind(this, 'loadMedia'),
|
|
||||||
// this.onLoadMediaError.bind(this));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -588,6 +597,7 @@
|
||||||
this.timer = setInterval(this.incrementMediaTimeHandler, this.timerStep);
|
this.timer = setInterval(this.incrementMediaTimeHandler, this.timerStep);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Create Cast Player
|
||||||
var castPlayer = new CastPlayer();
|
var castPlayer = new CastPlayer();
|
||||||
|
|
||||||
function getCodecLimits() {
|
function getCodecLimits() {
|
||||||
|
@ -917,6 +927,7 @@
|
||||||
if (item.MediaType == 'Audio') {
|
if (item.MediaType == 'Audio') {
|
||||||
|
|
||||||
url = ApiClient.serverAddress() + '/mediabrowser/audio/' + item.Id + '/stream.' + mediaSourceInfo.streamContainer + '?';
|
url = ApiClient.serverAddress() + '/mediabrowser/audio/' + item.Id + '/stream.' + mediaSourceInfo.streamContainer + '?';
|
||||||
|
|
||||||
url += '&static=' + mediaSourceInfo.isStatic.toString();
|
url += '&static=' + mediaSourceInfo.isStatic.toString();
|
||||||
url += '&maxaudiochannels=' + codecLimits.maxAudioChannels;
|
url += '&maxaudiochannels=' + codecLimits.maxAudioChannels;
|
||||||
|
|
||||||
|
@ -930,7 +941,7 @@
|
||||||
|
|
||||||
url += '&audiosamplerate=' + codecLimits.maxSampleRate;
|
url += '&audiosamplerate=' + codecLimits.maxSampleRate;
|
||||||
url += '&mediasourceid=' + mediaSourceInfo.mediaSource.Id;
|
url += '&mediasourceid=' + mediaSourceInfo.mediaSource.Id;
|
||||||
|
url += '&deviceId=' + ApiClient.deviceId();
|
||||||
return url;
|
return url;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -962,7 +973,7 @@
|
||||||
|
|
||||||
url += '&audiosamplerate=' + codecLimits.maxSampleRate;
|
url += '&audiosamplerate=' + codecLimits.maxSampleRate;
|
||||||
url += '&mediasourceid=' + mediaSourceInfo.mediaSource.Id;
|
url += '&mediasourceid=' + mediaSourceInfo.mediaSource.Id;
|
||||||
|
url += '&deviceId=' + ApiClient.deviceId();
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1265,9 +1276,8 @@
|
||||||
//$(MediaController).on('playerchange', function () {
|
//$(MediaController).on('playerchange', function () {
|
||||||
|
|
||||||
// if (MediaController.getPlayerInfo().name == PlayerName) {
|
// if (MediaController.getPlayerInfo().name == PlayerName) {
|
||||||
|
// if (castPlayer.deviceState != DEVICE_STATE.ACTIVE && castPlayer.isInitialized) {
|
||||||
// if (CastPlayer.deviceState != DEVICE_STATE.ACTIVE && CastPlayer.isInitialized) {
|
// castPlayer.launchApp();
|
||||||
// CastPlayer.launchApp();
|
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//});
|
//});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue