ultrawidify/src/csui/PlayerOverlay.vue

280 lines
7.1 KiB
Vue
Raw Normal View History

2020-12-15 00:26:19 +01:00
<template>
2022-06-11 15:40:36 +02:00
<div
2023-01-06 18:47:42 +01:00
v-if="settingsInitialized && uwTriggerZoneVisible"
2022-06-11 15:40:36 +02:00
class="uw-hover uv-hover-trigger-region uw-clickable"
:style="uwTriggerRegionConf"
@mouseenter="showUwWindow"
>
<h1>Aspect ratio controls</h1>
<div>Hover to activate</div>
</div>
2023-01-06 18:47:42 +01:00
<!-- sss -->
2022-06-11 15:40:36 +02:00
<div
2023-01-06 18:47:42 +01:00
v-if="settingsInitialized && uwWindowVisible"
class="uw-window flex flex-column uw-clickable"
2022-06-11 15:40:36 +02:00
:class="{'fade-out': uwWindowFadeOut}"
@mouseenter="cancelUwWindowHide"
@mouseleave="hideUwWindow"
>
2023-01-06 18:47:42 +01:00
<PlayerUIWindow
:settings="settings"
:eventBus="eventBus"
:logger="logger"
:in-player="true"
:site="site"
@close="uwWindowVisible = false"
@preventClose="(event) => uwWindowFadeOutDisabled = event"
></PlayerUIWindow>
2020-12-15 00:26:19 +01:00
</div>
</template>
<script>
2023-01-06 18:47:42 +01:00
import PlayerUIWindow from './src/PlayerUIWindow.vue'
2022-11-22 01:28:04 +01:00
import BaseExtensionSettings from './src/PlayerUiPanels/BaseExtensionSettings.vue'
2022-07-27 01:16:14 +02:00
import DebugPanel from './src/PlayerUiPanels/DebugPanel.vue'
import VideoSettings from './src/PlayerUiPanels/VideoSettings.vue'
2022-07-13 00:21:21 +02:00
import AutodetectionSettingsPanel from './src/PlayerUiPanels/AutodetectionSettingsPanel.vue'
2022-06-09 01:29:26 +02:00
import PlayerDetectionPanel from './src/PlayerUiPanels/PlayerDetectionPanel.vue'
2021-10-22 00:30:36 +02:00
// import Icon from '../common/components/Icon';
import ResizerDebugPanel from './src/PlayerUiPanels/ResizerDebugPanelComponent';
import BrowserDetect from '../ext/conf/BrowserDetect';
import Logger from '../ext/lib/Logger';
import Settings from '../ext/lib/Settings';
import EventBus from '../ext/lib/EventBus';
import UIProbeMixin from './src/utils/UIProbeMixin';
2020-12-15 00:26:19 +01:00
export default {
components: {
2021-10-22 00:30:36 +02:00
// Icon,
2022-06-09 01:29:26 +02:00
ResizerDebugPanel,
VideoSettings,
2022-07-13 00:21:21 +02:00
PlayerDetectionPanel,
2023-01-06 18:47:42 +01:00
AutodetectionSettingsPanel,
DebugPanel,
BaseExtensionSettings,
PlayerUIWindow
2020-12-15 00:26:19 +01:00
},
mixins: [
UIProbeMixin
],
2020-12-15 00:26:19 +01:00
data() {
return {
2022-06-11 15:40:36 +02:00
uwTriggerZoneVisible: false,
uwTriggerZoneTimeout: undefined,
uwTriggerRegionConf: {
left: "10%",
top: "10%",
height: "30%",
width: "30%",
maxWidth: "24rem",
maxHeight: "13.37rem",
},
uwWindowFadeOutDisabled: false,
2022-06-11 15:40:36 +02:00
uwWindowFadeOut: false,
uwWindowCloseTimeout: undefined,
uwWindowVisible: false,
// component properties
settings: {},
2021-10-22 00:30:56 +02:00
BrowserDetect: BrowserDetect,
settingsInitialized: false,
eventBus: new EventBus(),
logger: null,
// NOTE: chromium doesn't allow us to access window.parent.location
// meaning we will have to correct this value from our uwui-probe
// messages ... which is a bummer.
site: null,
origin: '*', // will be set appropriately once the first uwui-probe event is received
lastProbeTs: null,
uiVisible: true,
debugData: {
resizer: {},
player: {},
2020-12-16 01:40:09 +01:00
},
2022-03-28 23:14:52 +02:00
debugDataPrettified: '',
2022-07-28 00:45:27 +02:00
statusFlags: {
hasDrm: undefined,
},
2022-03-28 23:14:52 +02:00
tabs: [
{id: 'videoSettings', label: 'Video settings', icon: 'crop'},
2022-06-14 23:20:26 +02:00
{id: 'playerDetection', label: 'Player detection', icon: 'television-play'},
2022-11-22 01:28:04 +01:00
{id: 'extensionSettings', label: 'Extension options', icon: 'cogs' },
2022-03-28 23:14:52 +02:00
{id: 'autodetectionSettings', label: 'Autodetection options', icon: ''},
{id: 'advancedOptions', label: 'Advanced options', icon: 'cogs' },
{id: 'debugging', label: 'Debugging', icon: 'bug-outline' }
],
selectedTab: 'videoSettings',
2020-12-15 00:26:19 +01:00
};
},
computed: {
// LPT: NO ARROW FUNCTIONS IN COMPUTED,
// IS SUPER HARAM
// THINGS WILL NOT WORK IF YOU USE ARROWS
windowWidth() {
2020-12-16 01:40:09 +01:00
return window.innerWidth;
},
windowHeight() {
2020-12-16 01:40:09 +01:00
return window.innerHeight;
},
2020-12-15 00:26:19 +01:00
},
watch: {
showUi(visible) {
if (visible !== undefined) {
this.uiVisible = visible;
}
},
resizerDebugData(newData) {
this.debugData.resizer = newData;
2020-12-16 01:40:09 +01:00
this.debugDataPrettified = JSON.stringify(this.debugData, null, 2);
},
playerDebugData(newData) {
this.debugData.player = newData;
2020-12-16 01:40:09 +01:00
this.debugDataPrettified = JSON.stringify(this.debugData, null, 2);
2020-12-15 00:26:19 +01:00
}
},
2022-03-20 20:43:49 +01:00
async created() {
this.logger = new Logger();
// this prolly needs to be taken out
await this.logger.init({
allowLogging: true,
});
this.settings = new Settings({afterSettingsSaved: this.updateConfig, logger: this.logger});
await this.settings.init();
this.settingsInitialized = true;
2023-07-10 22:56:26 +02:00
// set up communication with client script.
// NOTE: companion onmousemove is set up in UIProbeMixin
window.addEventListener('message', event => {
this.handleMessage(event);
});
2022-07-30 00:47:11 +02:00
this.eventBus.subscribe('uw-config-broadcast', {function: (data) => {
2022-07-28 00:45:27 +02:00
if (data.type === 'drm-status') {
this.statusFlags.hasDrm = data.hasDrm;
}
2022-07-30 00:47:11 +02:00
}});
2020-12-15 00:26:19 +01:00
},
2020-12-15 00:26:19 +01:00
methods: {
/**
* Gets URL of the browser settings page (i think?)
*/
2020-12-22 03:14:03 +01:00
getUrl(url) {
2020-12-30 15:35:54 +01:00
return BrowserDetect.getURL(url);
},
/**
* Mostly intended to process messages received via window.addEventListener('message').
* This method should include minimal logic instead, it should only route messages
* to the correct function down the line.
*/
handleMessage(event) {
2022-03-22 01:21:18 +01:00
if (event.data.action === 'uwui-probe') {
if (!this.site) {
this.origin = event.origin;
this.site = event.origin.split('//')[1];
}
this.handleProbe(event.data, event.origin); // handleProbe is defined in UIProbeMixin
} else if (event.data.action === 'uw-bus-tunnel') {
this.handleBusTunnelIn(event.data.payload);
}
},
2022-06-11 15:40:36 +02:00
showUwWindow() {
this.uwWindowFadeOut = false;
this.uwWindowVisible = true;
this.uwTriggerZoneVisible = false;
2022-07-28 00:45:27 +02:00
// refresh DRM status
this.eventBus.send('get-drm-status');
2022-06-11 15:40:36 +02:00
},
hideUwWindow() {
if (this.uwWindowFadeOutDisabled) {
return;
}
2022-06-11 15:40:36 +02:00
this.uwWindowCloseTimeout = setTimeout(() => this.uwWindowVisible = false, 1100);
this.uwWindowFadeOut = true;
},
cancelUwWindowHide() {
this.uwWindowFadeOut = false;
clearTimeout(this.uwWindowCloseTimeout);
},
handleBusTunnelIn(payload) {
this.eventBus.send(payload.action, payload.config);
},
selectTab(tab) {
2022-06-09 01:29:26 +02:00
this.selectedTab = tab;
}
2020-12-15 00:26:19 +01:00
}
}
</script>
<style lang="scss" scoped>
@import 'res/css/uwui-base.scss';
@import 'res/css/colors.scss';
@import 'res/css/font/overpass.css';
@import 'res/css/font/overpass-mono.css';
@import 'res/css/common.scss';
@import './src/res-common/_variables';
.uw-hover {
position: absolute;
2020-12-16 01:40:09 +01:00
z-index: 999999999999999999;
}
2022-06-11 15:40:36 +02:00
.uv-hover-trigger-region {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
border: 0.5rem dashed #fff;
color: #fff;
backdrop-filter: blur(0.5rem) brightness(0.5);
}
2023-01-06 18:47:42 +01:00
.uw-window {
position: absolute;
top: 10%;
left: 10%;
z-index: 999999999999999999;
2020-12-16 01:40:09 +01:00
width: 2500px;
height: 1200px;
max-width: 80%;
max-height: 80%;
2020-12-16 01:40:09 +01:00
pointer-events: all !important;
2020-12-16 01:40:09 +01:00
2023-01-06 18:47:42 +01:00
opacity: 1;
backdrop-filter: blur(16px) saturate(120%);
2021-10-22 00:30:56 +02:00
2022-06-11 15:40:36 +02:00
&.fade-out {
opacity: 0;
2023-01-06 18:47:42 +01:00
transition: opacity 0.5s;
transition-delay: 0.5s;
2022-06-11 15:40:36 +02:00
}
}
2020-12-15 00:26:19 +01:00
</style>