Skip to content
Snippets Groups Projects

Feat: Flash playback using Ruffle

Merged Charlotte requested to merge CenTdemeern1/Sharkey:feat/ruffle into develop
Compare and
16 files
+ 699
3
Compare changes
  • Side-by-side
  • Inline
Files
16
@@ -21,7 +21,8 @@ SPDX-License-Identifier: AGPL-3.0-only
<template v-for="media in mediaList.filter(media => previewable(media))">
<XVideo v-if="media.type.startsWith('video')" :key="`video:${media.id}`" :class="$style.media" :video="media"/>
<XImage v-else-if="media.type.startsWith('image')" :key="`image:${media.id}`" :class="$style.media" class="image" :data-id="media.id" :image="media" :raw="raw"/>
<XModPlayer v-else-if="isModule(media)" :key="media.id" :module="media"/>
<XModPlayer v-else-if="isModule(media)" :key="`module:${media.id}`" :module="media"/>
<XFlashPlayer v-else-if="isFlash(media)" :key="media.id" :flashFile="media"/>
</template>
</div>
</div>
@@ -38,8 +39,9 @@ import XBanner from '@/components/MkMediaBanner.vue';
import XImage from '@/components/MkMediaImage.vue';
import XVideo from '@/components/MkMediaVideo.vue';
import XModPlayer from '@/components/SkModPlayer.vue';
import XFlashPlayer from '@/components/SkFlashPlayer.vue';
import * as os from '@/os.js';
import { FILE_TYPE_BROWSERSAFE, FILE_EXT_TRACKER_MODULES, FILE_TYPE_TRACKER_MODULES } from '@/const.js';
import { FILE_TYPE_BROWSERSAFE, FILE_EXT_TRACKER_MODULES, FILE_TYPE_TRACKER_MODULES, FILE_TYPE_FLASH_CONTENT, FILE_EXT_FLASH_CONTENT } from '@/const.js';
import { defaultStore } from '@/store.js';
import { focusParent } from '@/scripts/focus.js';
@@ -99,6 +101,12 @@ const isModule = (file: Misskey.entities.DriveFile): boolean => {
});
};
const isFlash = (file: Misskey.entities.DriveFile): boolean => {
return FILE_TYPE_FLASH_CONTENT.includes(file.type) || FILE_EXT_FLASH_CONTENT.some((ext) => {
return (file.name.toLowerCase().endsWith('.' + ext) || file.name.toLowerCase().endsWith('.' + ext + '.unknown'));
});
};
onMounted(() => {
calcAspectRatio();
@@ -224,6 +232,7 @@ const previewable = (file: Misskey.entities.DriveFile): boolean => {
if (file.type === 'image/svg+xml') return true; // svgのwebpublic/thumbnailはpngなのでtrue
// FILE_TYPE_BROWSERSAFEに適合しないものはブラウザで表示するのに不適切
if (isModule(file)) return true;
if (isFlash(file)) return true;
return (file.type.startsWith('video') || file.type.startsWith('image')) && FILE_TYPE_BROWSERSAFE.includes(file.type);
};
Loading