Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(core): stop media when audio block is removed (#11492)

pengx17fddf68f061c2
diff --git a/packages/frontend/core/src/modules/media/services/audio-attachment.ts b/packages/frontend/core/src/modules/media/services/audio-attachment.ts
index ad727a9acb..ca4959612c 100644
--- a/packages/frontend/core/src/modules/media/services/audio-attachment.ts
+++ b/packages/frontend/core/src/modules/media/services/audio-attachment.ts
@@ -35,6 +35,12 @@ export class AudioAttachmentService extends Service {
if (!exists) {
const entity = this.framework.createEntity(AudioAttachmentBlock, model);
exists = this.pool.put(key, entity);
+
+ const subscription = model.deleted.subscribe(() => {
+ entity.audioMedia.stop();
+ exists?.release();
+ });
+ this.disposables.push(() => subscription.unsubscribe());
}
return exists;
}