media-player/src/js/profile/MediaProfile.js
2025-07-08 16:50:48 +02:00

55 lines
1.3 KiB
JavaScript

import MediaProfileRole from "./MediaProfileRole.js";
import MediaProfileSettings from "./MediaProfileSettings.js";
import MediaProfileViewSettings from "./MediaProfileViewSettings.js";
export default class MediaProfile{
/**
* @type {string}
*/
name = "";
/**
* @type {string}
*/
role = MediaProfileRole.ADMIN;
/**
* @type {MediaProfileSettings}
*/
settings = new MediaProfileSettings();
/**
* @type {MediaProfileViewSettings}
*/
playSettings = new MediaProfileViewSettings();
/**
* @param {object} jsonObj
* @returns {MediaProfile}
*/
static fromJson(jsonObj) {
const profile = new MediaProfile();
if (jsonObj == null) {
return profile;
}
if (jsonObj.name != null) {
profile.name = jsonObj.name;
}
if (jsonObj.role != null) {
profile.role = jsonObj.role;
}
if (jsonObj.settings != null && typeof jsonObj.settings === "object") {
profile.settings = MediaProfileSettings.fromSettingsJson(jsonObj.settings);
}
if (jsonObj.playSettings != null && typeof jsonObj.playSettings === "object") {
profile.playSettings = MediaProfileViewSettings.fromSettingsJson(jsonObj.playSettings);
}
return profile;
}
}