Skip to content

Instantly share code, notes, and snippets.

@chanakaDe
Last active August 24, 2016 13:57
Show Gist options
  • Save chanakaDe/3a7d9faf84bee310b3917d2a5fce6823 to your computer and use it in GitHub Desktop.
Save chanakaDe/3a7d9faf84bee310b3917d2a5fce6823 to your computer and use it in GitHub Desktop.
/**
* Created by chanaka on 7/2/16.
*/
angular.module('data_visualize')
.controller('VideoCtrl', function ($scope, videoService, $routeParams, $sce, jwplayerService) {
var mobileStatus = mobilecheck();
console.log("MOBILE : " + mobileStatus);
var videoId = $routeParams.vid;
$scope.selectedVideoID = videoId;
//Checking mobile view or not and loading video.
if (mobileStatus) {
videoService.viewVideoByVidId(videoId, "VideoMobile").then(function (data) {
console.log("MOBILE URL : ", data.flvurl);
$scope.name = 'Video';
$scope.options = {
image: 'demo.jpg',
aspectratio: "4:3",
width: "120%",
rtmp: [{
bufferlength: 0.1,
securetoken: ""
}]
};
$scope.file = $sce.trustAsResourceUrl(data.flvurl);
});
} else {
videoService.viewVideoByVidId(videoId, "Video").then(function (data) {
console.log("FLV URL : ", data.flvurl);
$scope.name = 'Video';
$scope.options = {
image: 'demo.jpg',
height: 400,
width: 945,
rtmp: [{
bufferlength: 0.1,
securetoken: ""
}]
};
$scope.file = $sce.trustAsResourceUrl(data.flvurl);
});
}
videoService.viewVideoInfoByVidId(videoId).then(function (data) {
$scope.videoInfo = data;
console.log(data);
if (data.videocategory == 2) {
$scope.btnSD = true;
$scope.btnHD = true;
} else {
$scope.btnSD = true;
$scope.btnHD = false;
document.getElementById("btnSD").disabled = true;
}
});
$scope.optionsModal = {
image: 'demo.jpg',
aspectratio: "4:3",
width: "100%",
rtmp: [{
bufferlength: 0.1,
securetoken: ""
}]
};
$scope.openVideoModal = function (videoId) {
$('#videoModal').modal('show');
if (mobileStatus) {
videoService.viewVideoByVidId(videoId, "VideoMobile").then(function (data) {
console.log("MOBILE URL : ", data.flvurl);
$scope.file = $sce.trustAsResourceUrl(data.flvurl);
});
} else {
console.log("ELSE MODAL ACTIVATED");
videoService.viewVideoByVidId(videoId, "Video").then(function (data) {
console.log("FLV URL : ", data.flvurl);
$scope.file = $sce.trustAsResourceUrl(data.flvurl);
});
}
videoService.viewVideoInfoByVidId(videoId).then(function (data) {
$scope.videoInfo = data;
console.log(data);
if (data.videocategory == 2) {
$scope.btnSD = true;
$scope.btnHD = true;
} else {
$scope.btnSD = true;
$scope.btnHD = false;
document.getElementById("btnSD").disabled = true;
}
});
};
$('#videoModal').on('hidden.bs.modal', function () {
var player = jwplayerService.myPlayer[myPlayer2];
player.stop();
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment