mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-28 03:13:51 +02:00
Add Output.cancel
This commit is contained in:
+12
-2
@@ -20,6 +20,8 @@ export abstract class MediaSource {
|
||||
/** @internal */
|
||||
_connectedTrack: OutputTrack | null = null;
|
||||
/** @internal */
|
||||
_closing = false;
|
||||
/** @internal */
|
||||
_closed = false;
|
||||
/** @internal */
|
||||
_offsetTimestamps = false;
|
||||
@@ -30,6 +32,10 @@ export abstract class MediaSource {
|
||||
throw new Error('Cannot call digest without connecting the source to an output track.');
|
||||
}
|
||||
|
||||
if (this._connectedTrack.output._canceled) {
|
||||
throw new Error('Cannot call digest after output has been canceled.');
|
||||
}
|
||||
|
||||
if (!this._connectedTrack.output._started) {
|
||||
throw new Error('Cannot call digest before output has been started.');
|
||||
}
|
||||
@@ -48,8 +54,8 @@ export abstract class MediaSource {
|
||||
/** @internal */
|
||||
async _flush() {}
|
||||
|
||||
close() {
|
||||
if (this._closed) {
|
||||
async close() {
|
||||
if (this._closing) {
|
||||
throw new Error('Source already closed.');
|
||||
}
|
||||
|
||||
@@ -61,6 +67,10 @@ export abstract class MediaSource {
|
||||
throw new Error('Cannot call close before output has been started.');
|
||||
}
|
||||
|
||||
this._closing = true;
|
||||
|
||||
await this._flush();
|
||||
|
||||
this._closed = true;
|
||||
|
||||
if (this._connectedTrack.output._finalizing) {
|
||||
|
||||
Reference in New Issue
Block a user