Skip to content

Commit

Permalink
Move device capability reporting to a seperate function
Browse files Browse the repository at this point in the history
  • Loading branch information
YouKnowBlom committed Jun 8, 2020
1 parent 4372e2b commit c682482
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions src/components/maincontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,28 @@ window.mediaManager.addEventListener(

console.log('Application is ready, starting system');

export function reportDeviceCapabilities() {
getMaxBitrate("Video").then((maxBitrate) => {
let capabilitiesUrl = $scope.serverAddress + "/Sessions/Capabilities/Full";
let deviceProfile = getDeviceProfile(maxBitrate);

let capabilities = {
PlayableMediaTypes: ["Audio", "Video"],
SupportsPersistentIdentifier: false,
SupportsMediaControl: true,
DeviceProfile: deviceProfile
};
window.hasReportedCapabilities = true;
return ajax({
url: capabilitiesUrl,
headers: getSecurityHeaders($scope.accessToken, $scope.userId),
type: 'POST',
data: JSON.stringify(capabilities),
contentType: 'application/json'
});
});
}

export function processMessage(data) {

if (!data.command || !data.serverAddress || !data.userId || !data.accessToken) {
Expand All @@ -212,6 +234,7 @@ export function processMessage(data) {
return;
}

// Items will have properties - Id, Name, Type, MediaType, IsFolder
$scope.userId = data.userId;
$scope.accessToken = data.accessToken;
$scope.serverAddress = data.serverAddress;
Expand All @@ -221,25 +244,7 @@ export function processMessage(data) {

// Report device capabilities
if (!window.hasReportedCapabilities) {
getMaxBitrate("Video").then((maxBitrate) => {
let capabilitiesUrl = $scope.serverAddress + "/Sessions/Capabilities/Full";
let deviceProfile = getDeviceProfile(maxBitrate);

let capabilities = {
PlayableMediaTypes: ["Audio", "Video"],
SupportsPersistentIdentifier: false,
SupportsMediaControl: true,
DeviceProfile: deviceProfile
};
window.hasReportedCapabilities = true;
return ajax({
url: capabilitiesUrl,
headers: getSecurityHeaders($scope.accessToken, $scope.userId),
type: 'POST',
data: JSON.stringify(capabilities),
contentType: 'application/json'
});
});
reportDeviceCapabilities();
}

data.options = data.options || {};
Expand All @@ -252,8 +257,6 @@ export function processMessage(data) {
window.MaxBitrate = data.maxBitrate;
}

// Items will have properties - Id, Name, Type, MediaType, IsFolder

window.reportEventType;

let cmdHandler = window.commandHandler;
Expand Down

0 comments on commit c682482

Please sign in to comment.