1 | import { ToneAudioBuffer } from "../../core/context/ToneAudioBuffer.js";
|
2 | import { Positive, Seconds, Time } from "../../core/type/Units.js";
|
3 | import { Source, SourceOptions } from "../Source.js";
|
4 | export interface PlayerOptions extends SourceOptions {
|
5 | onload: () => void;
|
6 | onerror: (error: Error) => void;
|
7 | playbackRate: Positive;
|
8 | loop: boolean;
|
9 | autostart: boolean;
|
10 | loopStart: Time;
|
11 | loopEnd: Time;
|
12 | reverse: boolean;
|
13 | fadeIn: Time;
|
14 | fadeOut: Time;
|
15 | url?: ToneAudioBuffer | string | AudioBuffer;
|
16 | }
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | export declare class Player extends Source<PlayerOptions> {
|
26 | readonly name: string;
|
27 | |
28 |
|
29 |
|
30 |
|
31 | autostart: boolean;
|
32 | |
33 |
|
34 |
|
35 | private _buffer;
|
36 | |
37 |
|
38 |
|
39 | private _loop;
|
40 | |
41 |
|
42 |
|
43 | private _loopStart;
|
44 | |
45 |
|
46 |
|
47 | private _loopEnd;
|
48 | |
49 |
|
50 |
|
51 | private _playbackRate;
|
52 | |
53 |
|
54 |
|
55 | private _activeSources;
|
56 | |
57 |
|
58 |
|
59 | fadeIn: Time;
|
60 | |
61 |
|
62 |
|
63 | fadeOut: Time;
|
64 | |
65 |
|
66 |
|
67 |
|
68 | constructor(url?: string | AudioBuffer | ToneAudioBuffer, onload?: () => void);
|
69 | constructor(options?: Partial<PlayerOptions>);
|
70 | static getDefaults(): PlayerOptions;
|
71 | /**
|
72 | * Load the audio file as an audio buffer.
|
73 | * Decodes the audio asynchronously and invokes
|
74 | * the callback once the audio buffer loads.
|
75 | * Note: this does not need to be called if a url
|
76 | * was passed in to the constructor. Only use this
|
77 | * if you want to manually load a new url.
|
78 | * @param url The url of the buffer to load. Filetype support depends on the browser.
|
79 | */
|
80 | load(url: string): Promise<this>;
|
81 | /**
|
82 | * Internal callback when the buffer is loaded.
|
83 | */
|
84 | private _onload;
|
85 | /**
|
86 | * Internal callback when the buffer is done playing.
|
87 | */
|
88 | private _onSourceEnd;
|
89 | /**
|
90 | * Play the buffer at the given startTime. Optionally add an offset
|
91 | * and/or duration which will play the buffer from a position
|
92 | * within the buffer for the given duration.
|
93 | *
|
94 | * @param time When the player should start.
|
95 | * @param offset The offset from the beginning of the sample to start at.
|
96 | * @param duration How long the sample should play. If no duration is given, it will default to the full length of the sample (minus any offset)
|
97 | */
|
98 | start(time?: Time, offset?: Time, duration?: Time): this;
|
99 | /**
|
100 | * Internal start method
|
101 | */
|
102 | protected _start(startTime?: Time, offset?: Time, duration?: Time): void;
|
103 | /**
|
104 | * Stop playback.
|
105 | */
|
106 | protected _stop(time?: Time): void;
|
107 | /**
|
108 | * Stop and then restart the player from the beginning (or offset)
|
109 | * @param time When the player should start.
|
110 | * @param offset The offset from the beginning of the sample to start at.
|
111 | * @param duration How long the sample should play. If no duration is given,
|
112 | * it will default to the full length of the sample (minus any offset)
|
113 | */
|
114 | restart(time?: Seconds, offset?: Time, duration?: Time): this;
|
115 | protected _restart(time?: Seconds, offset?: Time, duration?: Time): void;
|
116 | /**
|
117 | * Seek to a specific time in the player's buffer. If the
|
118 | * source is no longer playing at that time, it will stop.
|
119 | * @param offset The time to seek to.
|
120 | * @param when The time for the seek event to occur.
|
121 | * @example
|
122 | * const player = new Tone.Player("https:
|
123 | * player.start();
|
124 | *
|
125 | * player.seek(0.4, "+1");
|
126 | * }).toDestination();
|
127 | */
|
128 | seek(offset: Time, when?: Time): this;
|
129 | /**
|
130 | * Set the loop start and end. Will only loop if loop is set to true.
|
131 | * @param loopStart The loop start time
|
132 | * @param loopEnd The loop end time
|
133 | * @example
|
134 | * const player = new Tone.Player("https:
|
135 | *
|
136 | * player.setLoopPoints(0.2, 0.3);
|
137 | * player.loop = true;
|
138 | * player.autostart = true;
|
139 | */
|
140 | setLoopPoints(loopStart: Time, loopEnd: Time): this;
|
141 | |
142 |
|
143 |
|
144 | get loopStart(): Time;
|
145 | set loopStart(loopStart: Time);
|
146 | |
147 |
|
148 |
|
149 | get loopEnd(): Time;
|
150 | set loopEnd(loopEnd: Time);
|
151 | |
152 |
|
153 |
|
154 | get buffer(): ToneAudioBuffer;
|
155 | set buffer(buffer: ToneAudioBuffer);
|
156 | |
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 | get loop(): boolean;
|
164 | set loop(loop: boolean);
|
165 | |
166 |
|
167 |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 |
|
174 | get playbackRate(): Positive;
|
175 | set playbackRate(rate: Positive);
|
176 | |
177 |
|
178 |
|
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 | get reverse(): boolean;
|
185 | set reverse(rev: boolean);
|
186 | |
187 |
|
188 |
|
189 | get loaded(): boolean;
|
190 | dispose(): this;
|
191 | }
|
192 |
|
\ | No newline at end of file |