tauri-plugin-native-audio-api 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-js/index.d.ts +28 -0
- package/dist-js/index.mjs +18 -0
- package/package.json +38 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type NativeAudioStatus = 'idle' | 'loading' | 'playing' | 'ended' | 'error';
|
|
2
|
+
|
|
3
|
+
export type NativeAudioState = {
|
|
4
|
+
status: NativeAudioStatus;
|
|
5
|
+
currentTime: number;
|
|
6
|
+
duration: number;
|
|
7
|
+
isPlaying: boolean;
|
|
8
|
+
buffering: boolean;
|
|
9
|
+
rate: number;
|
|
10
|
+
error?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type NativeAudioSetSourcePayload = {
|
|
14
|
+
src: string;
|
|
15
|
+
title?: string;
|
|
16
|
+
artist?: string;
|
|
17
|
+
artworkUrl?: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export declare const initialize: () => Promise<NativeAudioState>;
|
|
21
|
+
export declare const setSource: (payload: NativeAudioSetSourcePayload) => Promise<NativeAudioState>;
|
|
22
|
+
export declare const play: () => Promise<NativeAudioState>;
|
|
23
|
+
export declare const pause: () => Promise<NativeAudioState>;
|
|
24
|
+
export declare const seekTo: (position: number) => Promise<NativeAudioState>;
|
|
25
|
+
export declare const setRate: (rate: number) => Promise<NativeAudioState>;
|
|
26
|
+
export declare const getState: () => Promise<NativeAudioState>;
|
|
27
|
+
export declare const dispose: () => Promise<void>;
|
|
28
|
+
export declare const addStateListener: (handler: (state: NativeAudioState) => void) => Promise<() => void>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { addPluginListener, invoke } from '@tauri-apps/api/core';
|
|
2
|
+
|
|
3
|
+
const PLUGIN_NAME = 'native-audio';
|
|
4
|
+
const STATE_EVENT = 'native_audio_state';
|
|
5
|
+
|
|
6
|
+
const call = async (command, payload) => {
|
|
7
|
+
return await invoke(`plugin:${PLUGIN_NAME}|${command}`, payload);
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const initialize = async () => await call('initialize');
|
|
11
|
+
export const setSource = async (payload) => await call('set_source', payload);
|
|
12
|
+
export const play = async () => await call('play');
|
|
13
|
+
export const pause = async () => await call('pause');
|
|
14
|
+
export const seekTo = async (position) => await call('seek_to', { position });
|
|
15
|
+
export const setRate = async (rate) => await call('set_rate', { rate });
|
|
16
|
+
export const getState = async () => await call('get_state');
|
|
17
|
+
export const dispose = async () => await call('dispose');
|
|
18
|
+
export const addStateListener = async (handler) => await addPluginListener(PLUGIN_NAME, STATE_EVENT, handler);
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tauri-plugin-native-audio-api",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "JavaScript API for tauri-plugin-native-audio",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT OR Apache-2.0",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist-js"
|
|
9
|
+
],
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/uvarov-frontend/tauri-plugin-native-audio.git",
|
|
16
|
+
"directory": "guest-js"
|
|
17
|
+
},
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/uvarov-frontend/tauri-plugin-native-audio/issues"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/uvarov-frontend/tauri-plugin-native-audio",
|
|
22
|
+
"keywords": [
|
|
23
|
+
"tauri",
|
|
24
|
+
"tauri-plugin",
|
|
25
|
+
"audio",
|
|
26
|
+
"media3",
|
|
27
|
+
"avplayer"
|
|
28
|
+
],
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist-js/index.d.ts",
|
|
32
|
+
"import": "./dist-js/index.mjs"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@tauri-apps/api": ">=2.0.0"
|
|
37
|
+
}
|
|
38
|
+
}
|