forked from Blendman974/faceclaw
Add a video player, launched by selecting a video file from the Files app
This commit is contained in:
1 parent
deaa93fead
commit
cb6dddd120
13 files changed
+1784
-3
No files matched your search
@@ -2,6 +2,7 @@ import { readTextFile, type DirectoryEntry } from "../../native/file-access";
|
||||
import { isFontFile } from "../../native/font-files";
|
||||
import { installFontFile, isFontInstalled } from "../../graphics/installed-fonts";
|
||||
import { isDecodableImageFile } from "../../native/image-files";
|
||||
import { isPlayableVideoFile } from "../../native/video-player";
|
||||
import { readEvenHubPackageManifest } from "../evenhub/installed-apps";
|
||||
import { EvenHubPermissionDialogLayer } from "../evenhub/permission-dialog";
|
||||
import { FileBrowserLayer } from "./file-browser";
|
||||
@@ -35,17 +36,21 @@ export type FilesAppOptions = InProcessAppOptions & {
|
||||
installEhpkApp: (path: string) => Promise<void> | void;
|
||||
/** Open a font file's previewer as its own shell window. */
|
||||
openFontWindow: (title: string, path: string) => void;
|
||||
/** Open a video file's player (settings panel first) as its own shell window. */
|
||||
openVideoWindow: (title: string, path: string) => void;
|
||||
};
|
||||
|
||||
/**
|
||||
* The Files app's launcher-opened window: a file browser over Places
|
||||
* (bookmarks and storage roots). Picking any file opens an info dialog with
|
||||
* metadata plus, for viewable types (text, images), the open actions.
|
||||
* metadata plus, for viewable types (text, images, video), the open actions.
|
||||
*/
|
||||
export function createFilesAppWindow(options: FilesAppOptions): InProcessWindow {
|
||||
let created: InProcessWindow | null = null;
|
||||
const browser = new FileBrowserLayer({
|
||||
isSupportedFile: (name) => TEXT_FILE.test(name) || isFontFile(name) || EHPK_FILE.test(name) || (!global.isIOS && isDecodableImageFile(name)),
|
||||
isSupportedFile: (name) =>
|
||||
TEXT_FILE.test(name) || isFontFile(name) || EHPK_FILE.test(name) ||
|
||||
(!global.isIOS && (isDecodableImageFile(name) || isPlayableVideoFile(name))),
|
||||
// The browser handles double-click itself (up a level), so it is not
|
||||
// wrapped in YieldAtRootLayer; it yields explicitly from the top level.
|
||||
onLeave: () => shell.yieldFocusToSidebar(),
|
||||
@@ -230,6 +235,17 @@ function fileOpenActions(entry: DirectoryEntry, options: FilesAppOptions): FileI
|
||||
},
|
||||
];
|
||||
}
|
||||
if (isPlayableVideoFile(entry.name)) {
|
||||
return [
|
||||
{
|
||||
label: "Play video",
|
||||
onSelect: (ctx) => {
|
||||
ctx.stack.pop();
|
||||
options.openVideoWindow(entry.name, entry.path);
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
if (isFontFile(entry.name)) {
|
||||
// Install copies into the app-internal fonts directory, making the face
|
||||
// available in the Settings font pickers. The row relabels itself with
|
||||
|
||||
Reference in new issue
Block a user