mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-27 19:03:46 +02:00
Add metadata-based duration retrieval
This commit is contained in:
@@ -328,6 +328,13 @@ export class WaveDemuxer extends Demuxer {
|
||||
return null;
|
||||
}
|
||||
|
||||
async getDurationFromMetadata(): Promise<number | null> {
|
||||
await this.readMetadata();
|
||||
assert(this.dataSize !== -1);
|
||||
|
||||
return this.dataSize / this.audioInfo!.blockSizeInBytes / this.audioInfo!.sampleRate;
|
||||
}
|
||||
|
||||
async getMimeType() {
|
||||
return 'audio/wav';
|
||||
}
|
||||
@@ -414,6 +421,10 @@ class WaveAudioTrackBacking implements InputAudioTrackBacking {
|
||||
return null;
|
||||
}
|
||||
|
||||
getDurationFromMetadata() {
|
||||
return this.demuxer.getDurationFromMetadata();
|
||||
}
|
||||
|
||||
async getLiveRefreshInterval() {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user