diff --git a/.vscode/settings.json b/.vscode/settings.json
index 7a94be02..71081949 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -2,6 +2,7 @@
"cSpell.words": [
"akamaihd",
"alllangs",
+ "axios",
"ayfm",
"AYFM",
"cctv",
diff --git a/src-electron/electron-preload.ts b/src-electron/electron-preload.ts
index 417088fc..71f38b89 100644
--- a/src-electron/electron-preload.ts
+++ b/src-electron/electron-preload.ts
@@ -87,13 +87,17 @@ const moveMediaWindow = ({
const mediaWindow = getMediaWindow();
if (!mediaWindow || !mainWindow) return;
if (targetScreen === undefined || windowedMode === undefined) {
- const screenPreferences = JSON.parse(
- localStorage.getItem('screenPreferences') ?? '{}',
- ) as ScreenPreferences;
- // todo: fix this, not reading right values
- console.log('screenPreferences', screenPreferences);
- targetScreen = screenPreferences.preferredScreenNumber;
- windowedMode = screenPreferences.preferWindowed;
+ try {
+ const screenPreferences = JSON.parse(
+ localStorage.getItem('screenPreferences') ?? '{}',
+ ) as ScreenPreferences;
+ // todo: fix this, not reading right values
+ console.log('screenPreferences', screenPreferences);
+ targetScreen = screenPreferences.preferredScreenNumber;
+ windowedMode = screenPreferences.preferWindowed;
+ } catch (err) {
+ console.error(err);
+ }
}
const getWindowScreen = (window: Electron.BrowserWindow) => {
const windowDisplay = screen.getDisplayMatching(window.getBounds());
diff --git a/src/components/media/MediaDisplayButton.vue b/src/components/media/MediaDisplayButton.vue
index 49411f65..7ca1ef80 100644
--- a/src/components/media/MediaDisplayButton.vue
+++ b/src/components/media/MediaDisplayButton.vue
@@ -55,8 +55,8 @@
screen.mainWindow
? 'mdi-monitor-dashboard'
: screenPreferences.preferredScreenNumber === index
- ? 'mdi-monitor-shimmer'
- : 'mdi-monitor'
+ ? 'mdi-monitor-shimmer'
+ : 'mdi-monitor'
"
:text-color="
screenList.length < 2 ||
@@ -130,8 +130,7 @@ import { useAppSettingsStore } from 'src/stores/app-settings';
import { useCurrentStateStore } from 'src/stores/current-state';
import { onMounted, onUnmounted, ref, watch } from 'vue';
-const { getAllScreens, moveMediaWindow, toggleMediaWindow } =
- electronApi;
+const { getAllScreens, moveMediaWindow, toggleMediaWindow } = electronApi;
defineProps<{
disabled?: boolean;
@@ -178,13 +177,21 @@ watch(
);
const targetScreenListener = (event: CustomEventInit) => {
- console.log('targetScreen-update', event.detail);
- screenPreferences.value.preferredScreenNumber = event.detail;
+ try {
+ console.log('targetScreen-update', event.detail);
+ screenPreferences.value.preferredScreenNumber = event.detail;
+ } catch (error) {
+ console.error(error);
+ }
};
const windowedModeListener = (event: CustomEventInit) => {
- console.log('windowedMode-update', event.detail);
- screenPreferences.value.preferWindowed = event.detail;
+ try {
+ console.log('windowedMode-update', event.detail);
+ screenPreferences.value.preferWindowed = event.detail;
+ } catch (error) {
+ console.error(error);
+ }
};
onMounted(() => {
diff --git a/src/helpers/jw-media.ts b/src/helpers/jw-media.ts
index e0450c50..3919e7f6 100644
--- a/src/helpers/jw-media.ts
+++ b/src/helpers/jw-media.ts
@@ -1017,7 +1017,7 @@ const getPubMediaLinks = async (publication: PublicationFetcher) => {
};
export function findBestResolution(
- mediaLinks: (MediaItemsMediatorFile | MediaLink)[],
+ mediaLinks: MediaItemsMediatorFile[] | MediaLink[],
) {
const currentState = useCurrentStateStore();
const { getSettingValue } = currentState;
@@ -1033,7 +1033,9 @@ export function findBestResolution(
mediaLink.frameHeight <= maxRes &&
mediaLink.frameHeight >= bestHeight
) {
- bestItem = mediaLink;
+ bestItem = Object.hasOwn(mediaLink, 'progressiveDownloadURL')
+ ? (mediaLink as MediaItemsMediatorFile)
+ : (mediaLink as MediaLink);
bestHeight = mediaLink.frameHeight;
}
}
@@ -1114,6 +1116,32 @@ const downloadMissingMedia = async (publication: PublicationFetcher) => {
return downloadedFile?.path;
};
+const downloadAdditionalRemoteVideo = async (
+ mediaItemLinks: MediaItemsMediatorFile[],
+) => {
+ window.dispatchEvent(
+ new CustomEvent('remoteVideo-loading', {
+ detail: true,
+ }),
+ );
+ const currentState = useCurrentStateStore();
+ const { getDatedAdditionalMediaDirectory } = storeToRefs(currentState);
+ const bestItem = findBestResolution(mediaItemLinks) as MediaItemsMediatorFile;
+ let downloadedFile: DownloadedFile = { path: '' };
+ if (bestItem) {
+ downloadedFile = (await downloadFileIfNeeded({
+ dir: getDatedAdditionalMediaDirectory.value,
+ size: bestItem.filesize,
+ url: bestItem.progressiveDownloadURL,
+ })) as DownloadedFile;
+ }
+ window.dispatchEvent(
+ new CustomEvent('remoteVideo-loaded', {
+ detail: downloadedFile,
+ }),
+ );
+};
+
function getBestImageUrl(images: ImageTypeSizes, size?: keyof ImageSizes) {
const preferredOrder: (keyof ImageTypeSizes)[] = ['wss', 'lsr', 'sqr', 'pnr'];
for (const key of preferredOrder) {
@@ -1287,6 +1315,7 @@ const downloadJwpub = async (
export {
addFullFilePathToMultimediaItem,
+ downloadAdditionalRemoteVideo,
downloadBackgroundMusic,
downloadFileIfNeeded,
downloadPubMediaFiles,
diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue
index 865e69be..bd19c197 100644
--- a/src/layouts/MainLayout.vue
+++ b/src/layouts/MainLayout.vue
@@ -169,17 +169,20 @@
text-color="white"
/>
-