From 242d1be50d490522b97c303b2ac2eaeecb7a1b58 Mon Sep 17 00:00:00 2001 From: Dylan Hillerbrand Date: Thu, 24 Aug 2023 13:15:39 -0400 Subject: [PATCH] Stop chant audio when chant is changed --- .../js/app/manuscript-detail/folio/ChantRecordView.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nginx/public/node/frontend/public/js/app/manuscript-detail/folio/ChantRecordView.js b/nginx/public/node/frontend/public/js/app/manuscript-detail/folio/ChantRecordView.js index 53fb6d63..0cd59110 100644 --- a/nginx/public/node/frontend/public/js/app/manuscript-detail/folio/ChantRecordView.js +++ b/nginx/public/node/frontend/public/js/app/manuscript-detail/folio/ChantRecordView.js @@ -1,3 +1,4 @@ +import Backbone from 'backbone'; import Marionette from 'marionette'; import { parseVolpianoSyllables } from 'utils/VolpianoDisplayHelper'; @@ -6,6 +7,8 @@ import template from './chant-record.template.html'; import { MIDI } from 'utils/midi-player/midiPlayer.js'; +var manuscriptChannel = Backbone.Radio.channel('manuscript'); + MIDI.audioDetect(function (supports){ MIDI.supports = supports; var soundfontUrl = "/static/soundfonts/"; @@ -242,6 +245,7 @@ export default Marionette.ItemView.extend({ this.model.set('volpiano', formattedVolpiano); var cdb_uri = this.model.get('cdb_uri'); this.model.set({ 'cdb_link_url': 'https://cantus.uwaterloo.ca/node/' + cdb_uri }); + this.listenTo(manuscriptChannel, 'change:chant', this.chantChanged); }, ui : { volpianoSyllables: ".volpiano-syllable", @@ -260,5 +264,10 @@ export default Marionette.ItemView.extend({ }, stop: function(){ audioStopReset(MIDI); + }, + chantChanged: function(){ + if (MIDI.getContext().state === "running"){ + audioStopReset(MIDI); + } } });