get player select UI to work
This commit is contained in:
parent
3180063fe3
commit
bd1216c275
@ -390,13 +390,13 @@ export default({
|
||||
// if user agrees with ultrawidify on what element player should be,
|
||||
// we just unset our settings for this site
|
||||
if (this.elementStack[index].heuristics?.autoMatch) {
|
||||
await this.siteSettings.set('DOMConfig.modified.player.manual', false);
|
||||
await this.siteSettings.set('DOMConfig.modified.elements.player.manual', false);
|
||||
this.eventBus.sendToTunnel('get-player-tree');
|
||||
} else {
|
||||
// ensure settings exist:
|
||||
await this.siteSettings.set('DOMConfig.modified.player.manual', true, {noSave: true});
|
||||
await this.siteSettings.set('DOMConfig.modified.player.mode', 'index', {noSave: true});
|
||||
await this.siteSettings.set('DOMConfig.modified.player.index', index, true);
|
||||
await this.siteSettings.set('DOMConfig.modified.elements.player.manual', true, {noSave: true});
|
||||
await this.siteSettings.set('DOMConfig.modified.elements.player.mode', 'index', {noSave: true});
|
||||
await this.siteSettings.set('DOMConfig.modified.elements.player.index', index, true);
|
||||
this.eventBus.sendToTunnel('get-player-tree');
|
||||
}
|
||||
},
|
||||
|
@ -131,6 +131,9 @@ export class SiteSettings {
|
||||
if (parsedSettings._updateFlags?.forSite === this.site) {
|
||||
if (parsedSettings._updateFlags?.requireReload === true) {
|
||||
for (const key in this.storageChangeSubscriptions) {
|
||||
if (!this.storageChangeSubscriptions[key]) {
|
||||
continue;
|
||||
}
|
||||
for (const fn of this.storageChangeSubscriptions[key]) {
|
||||
fn(this, changes, area);
|
||||
}
|
||||
@ -138,7 +141,10 @@ export class SiteSettings {
|
||||
}
|
||||
else if (parsedSettings._updateFlags?.requireReload) {
|
||||
for (const key of parsedSettings._updateFlags?.requireReload) {
|
||||
console.log('reload required for:', key, this.storageChangeSubscriptions)
|
||||
console.log('reload required for:', key, this.storageChangeSubscriptions);
|
||||
|
||||
if (! this.storageChangeSubscriptions[key]) continue;
|
||||
|
||||
for (const fn of this.storageChangeSubscriptions[key]) {
|
||||
fn(this, changes, area);
|
||||
}
|
||||
|
@ -148,15 +148,16 @@ class PlayerData {
|
||||
document.addEventListener('fullscreenchange', this.trackDimensionChanges);
|
||||
|
||||
// we want to reload on storage changes
|
||||
this.siteSettings.subscribeToStorageChange('PlayerData', () => this.reloadPlayerDataConfig());
|
||||
this.siteSettings.subscribeToStorageChange('PlayerData', (siteConfUpdate) => this.reloadPlayerDataConfig(siteConfUpdate));
|
||||
} catch (e) {
|
||||
console.error('[Ultrawidify::PlayerData::ctor] There was an error setting up player data. You should be never seeing this message. Error:', e);
|
||||
this.invalid = true;
|
||||
}
|
||||
}
|
||||
|
||||
private reloadPlayerDataConfig() {
|
||||
private reloadPlayerDataConfig(siteConfUpdate) {
|
||||
console.log('reloading config ...')
|
||||
// this.siteSettings = siteConfUpdate;
|
||||
this.element = this.getPlayer();
|
||||
|
||||
console.log('got player:', this.element);
|
||||
@ -496,7 +497,7 @@ class PlayerData {
|
||||
const playerIndex = this.siteSettings.getPlayerIndex();
|
||||
|
||||
// on verbose, get both qs and index player
|
||||
if (options.verbose) {
|
||||
if (options?.verbose) {
|
||||
if (playerIndex) {
|
||||
playerCandidate = elementStack[playerIndex];
|
||||
playerCandidate.heuristics['manualElementByParentIndex'] = true;
|
||||
@ -505,15 +506,22 @@ class PlayerData {
|
||||
playerCandidate = this.getPlayerQs(playerQs, elementStack, videoWidth, videoHeight);
|
||||
}
|
||||
}
|
||||
|
||||
// if mode is given, we follow the preference
|
||||
if (this.siteSettings.data.currentDOMConfig?.elements?.player?.mode) {
|
||||
console.log('we prefer manual mode:', this.siteSettings, this.siteSettings.data.currentDOMConfig?.elements?.player);
|
||||
|
||||
if (this.siteSettings.data.currentDOMConfig?.elements?.player?.manual && this.siteSettings.data.currentDOMConfig?.elements?.player?.mode) {
|
||||
console.log('we prefer manual mode:', this.siteSettings.data.currentDOMConfig?.elements?.player?.mode);
|
||||
if (this.siteSettings.data.currentDOMConfig?.elements?.player?.mode === 'qs') {
|
||||
playerCandidate = this.getPlayerQs(playerQs, elementStack, videoWidth, videoHeight);
|
||||
console.log('got qs player candidate');
|
||||
} else {
|
||||
playerCandidate = elementStack[playerIndex];
|
||||
playerCandidate.heuristics['manualElementByParentIndex'] = true;
|
||||
console.log('got index player candidate')
|
||||
}
|
||||
} else {
|
||||
console.log('no preference.')
|
||||
// try to figure it out based on what we have, with playerQs taking priority
|
||||
if (playerQs) {
|
||||
playerCandidate = this.getPlayerQs(playerQs, elementStack, videoWidth, videoHeight);
|
||||
|
Loading…
Reference in New Issue
Block a user