UNPKG

unserver-unify

Version:

42 lines 1.27 kB
angular.module('bamboo.course').controller('WordChapterCtrl', function( $stateParams, ApiService) { this.cid = $stateParams.cid; console.log("--- WordChapterCtrl"); var self = this; this.index=0; this.currentPPT; var resUrl = ApiService.SHOST + '/lcourse/' + this.cid + '/resources/'; this.init = function(chapter) { self.chapter = chapter; resUrl = ApiService.SHOST + '/lcourse/' + self.chapter.cid + '/resources/'; console.log(self.chapter); self.show(0); // }, 100) } var myAudio this.playWord = function(word) { var file = self.chapter.libs[word]; if (!file) { return; } var filename = resUrl + file; try { // var myAudio = new Audio(filename); if(!myAudio){ myAudio = new Audio(filename); }else{ myAudio.pause(); myAudio.src=filename; } myAudio.play(); } catch (e) {} } this.show = function(index) { self.index = index; self.currentPPT = self.chapter.ppts[index]; if(self.currentPPT.photo){ self.currentPPT.photoUrl=resUrl+self.currentPPT.photo; } self.currentPPT.code = self.currentPPT.word.charCodeAt(0).toString(16); self.playWord(self.currentPPT.word); } });