- Timestamp:
- 2021-09-16T10:27:17+12:00 (3 years ago)
- 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
r35408 r35409 14 14 <transition-group name="transcription-list"> 15 15 <li class="list-item transcription-list-item" v-for="[id, transcription] in transcriptions" :key="id"> 16 <TranscriptionItem :transcription="transcription" @playAudio="playAudio($event)"/>16 <TranscriptionItem :transcription="transcription" /> 17 17 </li> 18 18 </transition-group> … … 82 82 translations: state => state.translations, 83 83 transcriptions: state => state.rawTranscriptions, 84 playbackState: state => state.playbackState 84 playbackState: state => state.playbackState, 85 shouldPlayAudio: state => state.playbackState.isPlaying 85 86 }), 86 methods: {87 /**88 * Plays transcription audio.89 * @param {{id: String, time: Number}} event The playback request event.90 */91 playAudio(event) { 92 const transcription = this.transcriptions.get( event.id);87 watch: { 88 playbackState(newValue) { 89 if (!newValue.isPlaying) { 90 return; 91 } 92 93 const transcription = this.transcriptions.get(newValue.id); 93 94 loadTranscriptionAudio(this.$refs.audioPlayer, this.$refs.audioPlayerSource, transcription, this.currentlyLoadedAudio); 94 95 95 if (event.time < 0) { 96 event.time = 0; 96 let playbackTime = 0; 97 if (newValue.currentTime > 0) { 98 playbackTime = newValue.currentTime; 97 99 } 98 100 99 this.$store.commit("setCurrentlyPlayingId", event.id); 100 101 this.$refs.audioPlayer.currentTime = event.time; 101 this.$refs.audioPlayer.currentTime = playbackTime; 102 102 this.$refs.audioPlayer.play(); 103 } 104 }, 105 watch: { 106 playbackState(newValue) { 107 console.log("Playback state changed."); 108 } 103 }//, 104 // shouldPlayAudio(newValue) { 105 // if (newValue && this.$refs.audioPlayer.paused) { 106 // this.$refs.audioPlayer.play(); 107 // } 108 // else if (!newValue && !this.$refs.audioPlayer.paused) { 109 // this.$refs.audioPlayer.pause(); 110 // } 111 // } 109 112 }, 110 113 mounted() { -
main/trunk/model-interfaces-dev/atea/korero-maori-asr/src/components/TranscriptionItem.vue
r35406 r35409 3 3 <!-- Header containing info and actions for the transcription --> 4 4 <div class="transcription__header"> 5 <button class="btn-fab" v-on:click="playAudio (0)" type="button">5 <button class="btn-fab" v-on:click="playAudio" type="button"> 6 6 <span class="material-icons mdi-l">play_arrow</span> 7 7 </button> … … 40 40 </div> 41 41 42 <TranscriptionItemEditor :transcription="transcription" @playAudio="playAudio($event)"/>42 <TranscriptionItemEditor :transcription="transcription" /> 43 43 44 44 <hr /> … … 96 96 import { saveAs } from "file-saver" 97 97 import TranscriptionItemEditor, { getWords } from "./TranscriptionItemEditor.vue" 98 import { TranscriptionViewModel } from "../main";98 import { TranscriptionViewModel, PlaybackState } from "../main"; 99 99 100 100 export default { … … 106 106 transcription: TranscriptionViewModel 107 107 }, 108 emits: [ "playAudio" ],109 108 data() { 110 109 return { … … 121 120 }, 122 121 playAudio(startTime = 0) { 123 this.$emit("playAudio", { id: this.transcription.id, time: startTime }); 122 const pState = new PlaybackState(this.transcription.id, true, startTime); 123 this.$store.commit("setPlaybackState", pState); 124 124 }, 125 125 remove() { -
main/trunk/model-interfaces-dev/atea/korero-maori-asr/src/components/TranscriptionItemEditor.vue
r35408 r35409 76 76 <script> 77 77 import { mapState } from "vuex"; 78 import { TranscriptionViewModel } from "../main";78 import { TranscriptionViewModel, PlaybackState } from "../main"; 79 79 import Util from "../js/Util"; 80 80 … … 119 119 } 120 120 }, 121 emits: [ "playAudio" ],122 121 computed: mapState({ 123 122 playbackState: state => state.playbackState, … … 127 126 methods: { 128 127 playAudio(startTime) { 129 this.$emit("playAudio", startTime); 128 const pState = new PlaybackState(this.transcription.id, true, startTime); 129 this.$store.commit("setPlaybackState", pState); 130 130 }, 131 131 /** -
main/trunk/model-interfaces-dev/atea/korero-maori-asr/src/main.js
r35408 r35409 30 30 31 31 export class PlaybackState { 32 constructor() { 32 /** 33 * Initialises a new instance of the {@link PlaybackState} class. 34 * @param {String} id The ID of the transcription for which audio is being played. 35 * @param {Boolean} isPlaying A value indicating if audio is currently being played. 36 * @param {Numbe} currentTime The current time in the audio playback. 37 */ 38 constructor(id = "", isPlaying = false, currentTime = -1) { 33 39 /** @type {String} The ID of the transcription for which audio is currently being played. */ 34 this.id = "";40 this.id = id; 35 41 36 42 /** @type {Boolean} Gets a value indicating if audio is currently being played back. */ 37 this.isPlaying = false;43 this.isPlaying = isPlaying; 38 44 39 45 /** @type {Number} Gets the current time in the playback. */ 40 this.currentTime = -1;46 this.currentTime = currentTime; 41 47 } 42 48 }
Note:
See TracChangeset
for help on using the changeset viewer.