Skip to content

Commit

Permalink
Remove unused functions from apphost.js, merge into nativeshell.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxr1998 committed Sep 5, 2020
1 parent 1595a52 commit 8b72541
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 176 deletions.
176 changes: 0 additions & 176 deletions app/src/main/assets/native/apphost.js

This file was deleted.

126 changes: 126 additions & 0 deletions app/src/main/assets/native/nativeshell.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
const features = [
"filedownload",
"displaylanguage",
//'externalplayerintent',
"subtitleappearancesettings",
//'sharing',
"exit",
"htmlaudioautoplay",
"htmlvideoautoplay",
"externallinks",
"clientsettings",
"multiserver",
"physicalvolumecontrol",
"remotecontrol",
"castmenuhashchange"
];

let deviceId;
let deviceName;
let appName;
let appVersion;

window.NativeShell = {
enableFullscreen() {
window.NativeInterface.enableFullscreen();
Expand Down Expand Up @@ -50,3 +72,107 @@ window.NativeShell = {
}
}
};

function getDeviceProfile(profileBuilder, item) {
const profile = profileBuilder({
enableMkvProgressive: false
});

profile.CodecProfiles = profile.CodecProfiles.filter(function (i) {
return i.Type === "Audio";
});

profile.SubtitleProfiles.push(
{
Format: "ssa",
Method: "External"
},
{
Format: "ass",
Method: "External"
}
);

profile.CodecProfiles.push({
Type: "Video",
Container: "avi",
Conditions: [
{
Condition: "NotEqual",
Property: "CodecTag",
Value: "xvid"
}
]
});

profile.CodecProfiles.push({
Type: "Video",
Codec: "h264",
Conditions: [
{
Condition: "EqualsAny",
Property: "VideoProfile",
Value: "high|main|baseline|constrained baseline"
},
{
Condition: "LessThanEqual",
Property: "VideoLevel",
Value: "41"
}]
});

profile.TranscodingProfiles.reduce(function (profiles, p) {
if (p.Type === "Video" && p.CopyTimestamps === true && p.VideoCodec === "h264") {
p.AudioCodec += ",ac3";
profiles.push(p);
}
return profiles;
}, []);

return profile;
}

window.NativeShell.AppHost = {
init() {
try {
const result = JSON.parse(window.NativeInterface.getDeviceInformation());
// set globally so they can be used elsewhere
deviceId = result.deviceId;
deviceName = result.deviceName;
appName = result.appName;
appVersion = result.appVersion;

return Promise.resolve({
deviceId,
deviceName,
appName,
appVersion,
});
} catch (e) {
return Promise.reject(e);
}
},
getDefaultLayout() {
return "mobile";
},
supports(command) {
return features.includes(command.toLowerCase());
},
getDeviceProfile,
getSyncProfile: getDeviceProfile,
deviceName() {
return deviceName;
},
deviceId() {
return deviceId;
},
appName() {
return appName;
},
appVersion() {
return appVersion;
},
exit() {
window.NativeInterface.exitApp();
}
};

0 comments on commit 8b72541

Please sign in to comment.