Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 118 additions & 0 deletions declarations/autojs6/aj6-int-mediainfo.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
// Type definitions for AutoJs6 internal module mediainfo
//
// Definitions by: SuperMonster003 <https://github.com/SuperMonster003>
// TypeScript Version: 5.1.3
//
// Last modified: Sep 1, 2026

/// <reference path="./index.d.ts" />

/**
* @Source %AutoJs6%/app/src/main/java/org/autojs/autojs/runtime/api/augment/mediainfo/Mediainfo.kt
* @Source %AutoJs6%/app/src/main/java/org/autojs/autojs/runtime/api/augment/mediainfo/MediainfoNativeObject.kt
* @Source %AutoJs6%/app/src/main/java/org/autojs/autojs/core/plugin/mediainfo/MediainfoPluginHost.kt
*/

declare namespace Internal {

interface Mediainfo {
(path: string): Mediainfo.Result;

readonly SNAPSHOT_SCHEMA_V1: 'autojs6-plugin-mediainfo-snapshot-v1';
readonly SNAPSHOT_SCHEMA_V2: 'autojs6-plugin-mediainfo-snapshot-v2';

read(path: string): Mediainfo.Result;

snapshot(path: string, options: Mediainfo.SnapshotOptions & { readonly schema: 'autojs6-plugin-mediainfo-snapshot-v1' }): Mediainfo.SnapshotV1;
snapshot(path: string, options: Mediainfo.SnapshotOptions & { readonly schema: 'autojs6-plugin-mediainfo-snapshot-v2' }): Mediainfo.SnapshotV2;
snapshot(path: string, options?: Mediainfo.DefaultSnapshotOptions): Mediainfo.SnapshotV1;
snapshot(path: string, options: Mediainfo.SnapshotOptions): Mediainfo.Snapshot;

capabilities(): Mediainfo.Capabilities;
}

}

declare namespace Mediainfo {

type StreamKind = 'general' | 'video' | 'audio' | 'text' | 'other' | 'image' | 'menu' | 'max';

type SnapshotSchema =
| 'autojs6-plugin-mediainfo-snapshot-v1'
| 'autojs6-plugin-mediainfo-snapshot-v2';

type SnapshotJsonPrimitive = string | number | boolean | null;
type SnapshotJsonValue = SnapshotJsonPrimitive | SnapshotJsonValue[] | { [key: string]: SnapshotJsonValue };

interface SnapshotOptions {
readonly includeInform?: boolean;
readonly includeSections?: boolean;
readonly schema?: SnapshotSchema;
}

interface DefaultSnapshotOptions extends SnapshotOptions {
readonly schema?: undefined;
}

interface SnapshotV1 {
readonly schema: 'autojs6-plugin-mediainfo-snapshot-v1';
readonly fileName: string;
readonly sizeBytes: number;
readonly inform: string;
readonly sections: Record<string, Array<Record<string, string>>>;
}

interface SnapshotV2Track {
readonly fields: Record<string, SnapshotJsonValue>;
readonly attributes?: Record<string, SnapshotJsonValue>;
readonly extra?: Record<string, SnapshotJsonValue>;
}

interface SnapshotV2 {
readonly schema: 'autojs6-plugin-mediainfo-snapshot-v2';
readonly file: {
readonly name: string;
readonly sizeBytes: number;
};
readonly engine: {
readonly name: string;
readonly version: string;
readonly url?: string;
};
readonly inform: string;
readonly tracks: Record<string, SnapshotV2Track[]>;
}

type Snapshot = SnapshotV1 | SnapshotV2;

interface Capabilities {
readonly snapshotSchemas: SnapshotSchema[];
readonly defaultSnapshotSchema: SnapshotSchema;
readonly engineVersion?: string;
}

interface StreamAccessor {
(parameter?: string): string;

[property: string]: string | ((parameter?: string) => string);
}

interface Result {
readonly path: string;
readonly inform: string;

readonly general: StreamAccessor;
readonly video: StreamAccessor;
readonly audio: StreamAccessor;
readonly text: StreamAccessor;
readonly other: StreamAccessor;
readonly image: StreamAccessor;
readonly menu: StreamAccessor;
readonly max: StreamAccessor;

toString(): string;

[section: string]: any;
}

}
3 changes: 2 additions & 1 deletion declarations/autojs6/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
/// <reference path="./aj6-int-init.d.ts" />
/// <reference path="./aj6-int-jvm-npm.d.ts" />
/// <reference path="./aj6-int-media.d.ts" />
/// <reference path="./aj6-int-mediainfo.d.ts" />
/// <reference path="./aj6-int-notice.d.ts" />
/// <reference path="./aj6-int-object-observe.d.ts" />
/// <reference path="./aj6-int-ocr.d.ts" />
Expand Down Expand Up @@ -56,4 +57,4 @@
/// <reference path="./aj6-mod-ant-forest.d.ts" />
/// <reference path="./aj6-mod-database.d.ts" />
/// <reference path="./aj6-mod-global.d.ts" />
/// <reference path="./aj6-plugin-autojs-memory-info.d.ts" />
/// <reference path="./aj6-plugin-autojs-memory-info.d.ts" />
15 changes: 15 additions & 0 deletions docs/smoke/mediainfo-snapshot-v2-smoke.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
declare const mediainfoApi: Internal.Mediainfo;

const legacyResult: Mediainfo.Result = mediainfoApi('./sample.mp4');
const defaultSnapshot: Mediainfo.SnapshotV1 = mediainfoApi.snapshot('./sample.mp4');
const snapshotV1: Mediainfo.SnapshotV1 = mediainfoApi.snapshot('./sample.mp4', {
schema: mediainfoApi.SNAPSHOT_SCHEMA_V1,
includeSections: true,
});
const snapshotV2: Mediainfo.SnapshotV2 = mediainfoApi.snapshot('./sample.mp4', {
schema: mediainfoApi.SNAPSHOT_SCHEMA_V2,
includeInform: false,
});
const capabilities: Mediainfo.Capabilities = mediainfoApi.capabilities();

void [legacyResult, defaultSnapshot, snapshotV1, snapshotV2, capabilities];