Ignore:
Timestamp:
2021-09-16T11:10:39+12:00 (3 years ago)
Author:
cstephen
Message:

Use unbound audio object.
Update translations.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/model-interfaces-dev/atea/korero-maori-asr/src/App.vue

    r35409 r35411  
    22    <!-- Used to calculate the character size of our monospace font -->
    33    <span class="monospace-font-sizer">ngā tama a rangi</span>
    4 
    5     <audio id="transcriptionAudio" ref="audioPlayer">
    6         <source id="transcriptionAudioSource" ref="audioPlayerSource" />
    7     </audio>
    84
    95    <div class="paper">
     
    7672        return {
    7773            /** @type {{id: String, url: String} | null} */
    78             currentlyLoadedAudio: null
     74            currentlyLoadedAudio: null,
     75            player: new Audio()
    7976        }
    8077    },
     
    8683    }),
    8784    watch: {
    88         playbackState(newValue) {
     85        async playbackState(newValue) {
    8986            if (!newValue.isPlaying) {
    9087                return;
     
    9289
    9390            const transcription = this.transcriptions.get(newValue.id);
    94             loadTranscriptionAudio(this.$refs.audioPlayer, this.$refs.audioPlayerSource, transcription, this.currentlyLoadedAudio);
     91            loadTranscriptionAudio(this.player, transcription, this.currentlyLoadedAudio);
    9592
    9693            let playbackTime = 0;
     
    9996            }
    10097
    101             this.$refs.audioPlayer.currentTime = playbackTime;
    102             this.$refs.audioPlayer.play();
     98            this.player.currentTime = playbackTime;
     99            await this.player.play();
    103100        }//,
    104101        // shouldPlayAudio(newValue) {
     
    112109    },
    113110    mounted() {
    114         pollAudioTime(this.$refs.audioPlayer, this.$store);
     111        pollAudioTime(this.player, this.$store);
    115112    }
    116113}
     
    135132/**
    136133 * Loads an audio file.
     134 * @param {Audio} player The audio player.
    137135 * @param {TranscriptionViewModel} transcription The name of the requested audio file.
    138136 * @param {{id: String, url: String} | null} current The currently loaded audio.
    139137 * @returns {{id: String, url: String}} If a new audio file was loaded, a new audio tracking object, else the current one.
    140138 */
    141 function loadTranscriptionAudio(audioElement, audioElementSource, transcription, current) {
     139function loadTranscriptionAudio(player, transcription, current) {
    142140    if (current == null || current.id !== transcription.id) {
    143141        // TODO: Need to profile on some larger tracks; this may not be worth it? Better to cache a URL object instead?
     
    147145
    148146        const urlObject = URL.createObjectURL(transcription.file);
    149         audioElementSource.src = urlObject;
    150         audioElement.load();
     147        player.src = urlObject;
     148        player.load();
    151149
    152150        return { id: transcription.id, url: urlObject };
Note: See TracChangeset for help on using the changeset viewer.