Changeset 35408 for main


Ignore:
Timestamp:
2021-09-16T10:06:12+12:00 (3 years ago)
Author:
cstephen
Message:

Fix word highlighting occuring globally

Location:
main/trunk/model-interfaces-dev/atea/korero-maori-asr/src
Files:
4 edited

Legend:

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

    r35407 r35408  
    6363
    6464<script>
     65import { mapState } from "vuex";
    6566import AudioUpload from "./components/AudioUpload.vue"
    6667import TranscriptionItem from "./components/TranscriptionItem.vue"
     
    7879        }
    7980    },
    80     computed: {
    81         transcriptions() {
    82             return this.$store.state.rawTranscriptions;
    83         }
    84     },
     81    computed: mapState({
     82        translations: state => state.translations,
     83        transcriptions: state => state.rawTranscriptions,
     84        playbackState: state => state.playbackState
     85    }),
    8586    methods: {
    8687        /**
     
    9697            }
    9798
     99            this.$store.commit("setCurrentlyPlayingId", event.id);
     100
    98101            this.$refs.audioPlayer.currentTime = event.time;
    99102            this.$refs.audioPlayer.play();
     103        }
     104    },
     105    watch: {
     106        playbackState(newValue) {
     107            console.log("Playback state changed.");
    100108        }
    101109    },
  • main/trunk/model-interfaces-dev/atea/korero-maori-asr/src/components/AudioUpload.vue

    r35407 r35408  
    33    <div class="audio-file-picker">
    44        <div class="input-bar">
    5             <!-- <button type="button" v-on:click="openFilePicker">
    6                 <span class="material-icons">&#xE2C6;</span> file_upload
    7                 <span>Upload Audio Files</span>
    8             </button>-->
    9 
    105            <div class="text-input-sl" style="cursor: pointer;" @click="openFilePicker">
    116                <span class="text-placeholder material-icons" v-if="!anyFiles">&#xe226;</span> <!-- attach_file -->
  • main/trunk/model-interfaces-dev/atea/korero-maori-asr/src/components/TranscriptionItemEditor.vue

    r35405 r35408  
    121121    emits: [ "playAudio" ],
    122122    computed: mapState({
    123         currentPlaybackTime: state => state.currentPlaybackTime,
     123        playbackState: state => state.playbackState,
     124        currentPlaybackTime: state => state.playbackState.currentTime,
    124125        translations: state => state.translations
    125126    }),
     
    233234            this.words[this.lastHighlightedWord].shouldHighlight = false;
    234235
    235             if (!this.$store.state.isCurrentlyPlaying) {
    236                 return -1;
     236            if (!this.playbackState.isPlaying || this.playbackState.id !== this.transcription.id) {
     237                return;
    237238            }
    238239
     
    240241                word.shouldHighlight = word.startTime < newValue && word.endTime > newValue;
    241242            }
    242 
    243             return -1;
    244243        }
    245244    },
  • main/trunk/model-interfaces-dev/atea/korero-maori-asr/src/main.js

    r35399 r35408  
    2929}
    3030
     31export class PlaybackState {
     32    constructor() {
     33        /** @type {String} The ID of the transcription for which audio is currently being played. */
     34        this.id = "";
     35
     36        /** @type {Boolean} Gets a value indicating if audio is currently being played back. */
     37        this.isPlaying = false;
     38
     39        /** @type {Number} Gets the current time in the playback. */
     40        this.currentTime = -1;
     41    }
     42}
     43
    3144const store = createStore({
    3245    state() {
     
    3649            /** @type {Map<String, TranscriptionViewModel>} */
    3750            rawTranscriptions: new Map(),
    38             isCurrentlyPlaying: false,
    39             currentPlaybackTime: -1
     51            playbackState: new PlaybackState()
    4052        }
    4153    },
     
    4961            state.rawTranscriptions.set(transcription.id, transcription);
    5062        },
     63
     64        /**
     65         * Removes a transcription from the store.
     66         * @param {*} state The state of the store.
     67         * @param {String} id The UUID of the transcription.
     68         */
    5169        transcriptionRemove(state, id) {
    5270            state.rawTranscriptions.delete(id);
    5371        },
     72
     73        /**
     74         * Sets the current playback state.
     75         * @param {*} state The state of the store.
     76         * @param {PlaybackState} playbackState The new playback state.
     77         */
     78        setPlaybackState(state, playbackState) {
     79            state.playbackState = playbackState;
     80        },
    5481        setCurrentlyPlaying(state, isPlaying) {
    55             state.isCurrentlyPlaying = isPlaying;
     82            state.playbackState.isPlaying = isPlaying;
    5683        },
    5784        setCurrentPlaybackTime(state, time) {
    58             state.currentPlaybackTime = time;
     85            state.playbackState.currentTime = time;
     86        },
     87        setCurrentlyPlayingId(state, id) {
     88            state.playbackState.id = id;
    5989        },
    6090        setTranslations(state, translations) {
     
    6797    .use(store)
    6898    .mount("#app");
     99
     100/* === Get interface translations === */
    69101
    70102/** @type {Map<String, String>} */
Note: See TracChangeset for help on using the changeset viewer.