unserver-unify
Version:
162 lines (151 loc) • 4.94 kB
JavaScript
;
angular.module('bamboo.playback').controller('AudioPlaybackItemCtrl', function($sce, ApiService, $stateParams, $timeout, $scope, loginService, $rootScope, $q, UserService) {
var self = this;
$rootScope.fullwidthflag = true;
// $rootScope.hideHeader = true;
$rootScope.fullwidth = true;
this.id = $stateParams.id;
this.pptSlides = [];
this.audioURL = ApiService.SHOST + '/tempaudio/';
this.playback = {};
this.currentPPT = {};
this.slides = {};
this.index = 0;
this.picURL = ApiService.SHOST + '/videoslide/';
this.currentImg = '';
this.chatHistory = [];
function getInfo() {
var info = {
action: "getAudioPlayback",
id: self.id,
}
ApiService.post("/vmeeting", info).then(function(result) {
console.log(result);
if (result.data.success) {
self.item = result.data.data || {};
self.history = self.item.history;
if(self.item.creater){
getCreatorDetails();
}
console.log(self.history);
//loadHistory();
loadMobileData();
self.imageUrl = self.item.photo ? self.contentModelPicUrl + self.item.photo : null;
}
});
}
getInfo();
function getCreatorDetails()
{
var info = {
action: "getUserNamesByIds",
ids: [self.item.creater]
}
console.log(info);
UserService.UserApi(info, function(result) {
console.log(result);
if(result&&result.length!=0){
self.creater = result[0];
self.createrImg = ApiService.PSURL + "/avatar/"+self.item.creater+"/"+self.creater.avatar;
}
});
}
this.showTab = "description";
this.show = function(tab) {
self.showTab = tab;
};
// this.toggleHeader = function() {
// $rootScope.hideHeader = !$rootScope.hideHeader;
// }
function loadHistory(){
self.currentPage = self.history[self.index];
console.log(self.currentPage);
loadData();
console.log(self.history.length);
console.log(self.index);
if(self.history.length!=self.index+1){
self.nextPage = self.history[self.index+1];
var timeout = (self.nextPage.refTime - self.currentPage.refTime)*1000;
console.log(timeout);
$timeout(function() {
self.index++;
loadHistory();
},timeout);
}
}
function loadData(){
if(self.currentPage.type=='setPPT'&&self.currentPage.data) {
getSlides(self.currentPage.data.pptId);
} else if(self.currentPage.type=='audioUrl'&&self.currentPage.file){
var audio = angular.element('#playAudio');
if(audio[0]){
audio[0].pause();
}
self.playAudio = $sce.trustAsResourceUrl(self.audioURL + encodeURI(self.currentPage.file));
console.log(self.playAudio);
if(audio[0]){
audio[0].src = self.playAudio;
audio[0].play();
}
} else if(self.currentPage.type=='setPage'&&self.currentPage.data){
if(self.currentPPT._id==self.currentPage.data.pptId){
self.pptPage = self.currentPPT.ppts[self.currentPage.data.index];
}
}
}
//getPPT();
// function getPPT(){
// var info = {
// action: "getmyslide",
// }
// ApiService.post('/vmeeting', info).then(function(result) {
// if (result.data.success) {
// self.currentPPT = result.data.data;
// console.log(self.currentPPT);
// }
// });
// }
function getSlides(id){
var deferred = $q.defer();
var info = {
action: "getslide",
id: id,
}
console.log(info);
ApiService.post('/vmeeting', info).then(function(result) {
if (result.data.success) {
self.currentPPT = result.data.data;
self.slides[id] = result.data.data;
console.log(self.currentPPT);
deferred.resolve(true);
//var uid = self.currentPPT.uid;
//self.picURL = ApiService.SHOST + '/videoslide/' + uid + "/";
// if(self.currentPPT.ppts&&self.currentPPT.ppts.length!=0)
// {
// self.pptPage = self.currentPPT.ppts[0];
// }
} else {
deferred.resolve(true);
}
});
return deferred.promise;
}
function loadMobileData(){
angular.forEach(self.history,function(his){
if(his.type=='setPPT'&&his.data.pptId) {
getSlides(his.data.pptId);
} else if(his.type=='setPage'&&his.data&&!self.currentImg){
self.currentImg = his.data;
} else if(his.type=='message'||his.type=='chat'){
self.chatHistory.push(his);
}
});
}
this.setSlideImg = function(his){
self.currentImg = his.data;
}
this.getPPtPicUrl = function(item) {
var uid = item._id;
return $sce.trustAsResourceUrl(ApiService.SHOST + '/videoslide/' + uid + "/" + encodeURI(item.name));
};
});