Skip to content

Commit

Permalink
Move playMediaSource to playbackManager class
Browse files Browse the repository at this point in the history
  • Loading branch information
YouKnowBlom committed Jun 10, 2020
1 parent d36a8c7 commit 30cb9b9
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 43 deletions.
42 changes: 0 additions & 42 deletions src/components/maincontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -665,48 +665,6 @@ export function createMediaInformation(playSessionId, item, streamInfo) {
return mediaInfo;
}

export function playMediaSource(playSessionId, item, mediaSource, options) {

setAppStatus('loading');

var streamInfo = createStreamInfo(item, mediaSource, options.startPositionTicks);

var url = streamInfo.url;

var mediaInfo = createMediaInformation(playSessionId, item, streamInfo);
var loadRequestData = new cast.framework.messages.LoadRequestData();
loadRequestData.media = mediaInfo;
loadRequestData.autoplay = true;

jellyfinActions.load($scope, mediaInfo.customData, item);
window.mediaManager.load(loadRequestData);

$scope.PlaybackMediaSource = mediaSource;

console.log('setting src to ' + url);
$scope.mediaSource = mediaSource;

if (item.BackdropImageTags && item.BackdropImageTags.length) {
backdropUrl = $scope.serverAddress + '/emby/Items/' + item.Id + '/Images/Backdrop/0?tag=' + item.BackdropImageTags[0];
} else if (item.ParentBackdropItemId && item.ParentBackdropImageTags && item.ParentBackdropImageTags.length) {
backdropUrl = $scope.serverAddress + '/emby/Items/' + item.ParentBackdropItemId + '/Images/Backdrop/0?tag=' + item.ParentBackdropImageTags[0];
}

if (backdropUrl) {
window.mediaElement.style.setProperty('--background-image', 'url("' + backdropUrl + '")');
} else {
//Replace with a placeholder?
window.mediaElement.style.removeProperty('--background-image');
}

jellyfinActions.reportPlaybackStart($scope, getReportingParams($scope));

// We use false as we do not want to broadcast the new status yet
// we will broadcast manually when the media has been loaded, this
// is to be sure the duration has been updated in the media element
window.mediaManager.setMediaInformation(mediaInfo, false);
}

playbackConfig.supportedCommands = cast.framework.messages.Command.ALL_BASIC_MEDIA;

// Set the available buttons in the UI controls.
Expand Down
47 changes: 46 additions & 1 deletion src/components/playbackManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import {
getOptimalMediaSource,
validatePlaybackInfoResult,
showPlaybackInfoErrorMessage,
supportsDirectPlay
supportsDirectPlay,
createStreamInfo,
createMediaInformation
} from "./maincontroller";

import { factory as jellyfinActions } from "./jellyfinactions";
Expand Down Expand Up @@ -144,6 +146,49 @@ export class playbackManager {
});
}

playMediaSource(playSessionId, item, mediaSource, options) {

setAppStatus('loading');

var streamInfo = createStreamInfo(item, mediaSource, options.startPositionTicks);

var url = streamInfo.url;

var mediaInfo = createMediaInformation(playSessionId, item, streamInfo);
var loadRequestData = new cast.framework.messages.LoadRequestData();
loadRequestData.media = mediaInfo;
loadRequestData.autoplay = true;

jellyfinActions.load($scope, mediaInfo.customData, item);
this.playerManager.load(loadRequestData);

$scope.PlaybackMediaSource = mediaSource;

console.log('setting src to ' + url);
$scope.mediaSource = mediaSource;

let backdropUrl;
if (item.BackdropImageTags && item.BackdropImageTags.length) {
backdropUrl = $scope.serverAddress + '/emby/Items/' + item.Id + '/Images/Backdrop/0?tag=' + item.BackdropImageTags[0];
} else if (item.ParentBackdropItemId && item.ParentBackdropImageTags && item.ParentBackdropImageTags.length) {
backdropUrl = $scope.serverAddress + '/emby/Items/' + item.ParentBackdropItemId + '/Images/Backdrop/0?tag=' + item.ParentBackdropImageTags[0];
}

if (backdropUrl) {
window.mediaElement.style.setProperty('--background-image', 'url("' + backdropUrl + '")');
} else {
//Replace with a placeholder?
window.mediaElement.style.removeProperty('--background-image');
}

jellyfinActions.reportPlaybackStart($scope, getReportingParams($scope));

// We use false as we do not want to broadcast the new status yet
// we will broadcast manually when the media has been loaded, this
// is to be sure the duration has been updated in the media element
this.playerManager.setMediaInformation(mediaInfo, false);
}

stop(nextMode) {

$scope.playNextItem = nextMode ? true : false;
Expand Down

0 comments on commit 30cb9b9

Please sign in to comment.