Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DocumentManager #93

Merged
merged 15 commits into from
Jan 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ module.exports = {
plugins: ['@typescript-eslint', 'prettier', 'promise', 'import', 'jsdoc'],
env: {
node: true,
es6: true
es6: true,
browser: true
},
extends: [
'eslint:recommended',
Expand Down
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ dist/
node_modules/
src/api/generated/

*.html
LICENSE.md
6 changes: 2 additions & 4 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"extends": "stylelint-config-standard",
"rules": {
"indentation": 4
}
"extends": ["stylelint-config-standard", "stylelint-config-prettier"],
"rules": {}
}
1 change: 1 addition & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { RepeatMode } from './api/generated/models/repeat-mode';
import './components/maincontroller';
import './css/glyphicons.css';
import './css/jellyfin.css';

const senders = cast.framework.CastReceiverContext.getInstance().getSenders();
Expand Down
16 changes: 11 additions & 5 deletions src/components/castDevices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,31 @@ export enum deviceIds {
CCGTV //Chromecast Google TV
}

// cached device id, avoid looking it up again and again
let deviceId: number | null = null;

/**
* Get device id of the active Cast device.
* Tries to identify the active Cast device by testing support for different codecs.
*
* @returns Active Cast device Id.
*/
export function getActiveDeviceId(): number {
if (deviceId !== null) return deviceId;

if (
castContext.canDisplayType('video/mp4', 'hev1.1.6.L153.B0') &&
castContext.canDisplayType('video/webm', 'vp9')
) {
return deviceIds.ULTRA;
deviceId = deviceIds.ULTRA;
} else if (castContext.canDisplayType('video/webm', 'vp9')) {
return deviceIds.NESTHUBANDMAX;
deviceId = deviceIds.NESTHUBANDMAX;
} else if (castContext.canDisplayType('video/mp4', 'avc1.64002A')) {
return deviceIds.GEN3;
deviceId = deviceIds.GEN3;
} else if (castContext.canDisplayType('video/mp4', 'avc1.640029')) {
return deviceIds.GEN1AND2;
deviceId = deviceIds.GEN1AND2;
} else {
return deviceIds.AUDIO;
deviceId = deviceIds.AUDIO;
}
return deviceId;
}
12 changes: 5 additions & 7 deletions src/components/commandHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ import {
seek
} from './maincontroller';

import {
displayItem,
reportPlaybackProgress,
startBackdropInterval
} from './jellyfinActions';
import { reportPlaybackProgress } from './jellyfinActions';

import { playbackManager } from './playbackManager';

import { DocumentManager } from './documentManager';

export abstract class CommandHandler {
private static playerManager: cast.framework.PlayerManager;
private static playbackManager: playbackManager;
Expand Down Expand Up @@ -92,7 +90,7 @@ export abstract class CommandHandler {

static displayContentHandler(data: DataMessage): void {
if (!this.playbackManager.isPlaying()) {
displayItem((<DisplayRequest>data.options).ItemId);
DocumentManager.showItemId((<DisplayRequest>data.options).ItemId);
}
}

Expand Down Expand Up @@ -141,7 +139,7 @@ export abstract class CommandHandler {

static IdentifyHandler(): void {
if (!this.playbackManager.isPlaying()) {
startBackdropInterval();
DocumentManager.startBackdropInterval();
} else {
// When a client connects send back the initial device state (volume etc) via a playbackstop message
reportPlaybackProgress(
Expand Down
10 changes: 5 additions & 5 deletions src/components/deviceprofileBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ let profileOptions: ProfileOptions;
let currentDeviceId: number;

/**
* @param Property What property the condition should test.
* @param Condition The condition to test the values for.
* @param Value The value to compare against.
* @param [IsRequired=false]
hawken93 marked this conversation as resolved.
Show resolved Hide resolved
* @returns A profile condition created from the parameters.
* @param {ProfileConditionValue} Property What property the condition should test.
* @param {ProfileConditionType} Condition The condition to test the values for.
* @param {string} Value The value to compare against.
* @param {boolean} [IsRequired=false] Don't permit unknown values
* @returns {ProfileCondition} A profile condition created from the parameters.
*/
function createProfileCondition(
Property: ProfileConditionValue,
Expand Down
Loading