I'm trying to use JWPlayer to steam videos on an Ionic app. But I'm facing an issue.
The player only loads on page refresh and not when I'm browsing through the list of videos.
Following is the code of my controller
.controller('VideosCtrl', function($scope, $http) {
$http.get('http://www.example.com/api/apps-videos').success(function(data, status, headers, config) {
$scope.videos = data;
$scope.video = data.filter(function(e){
return e.id === $stateParams.videoId;
})[0];
jwplayer("jwPlayer").setup({
file: $scope.video.playurl,
image: $scope.video.video_image,
skin: "bekle"
});
});
})
Since I'm a noob, and don't know how to pass $scope variable to javascript, I've called jwplayer().setup() in the controller itself.
It works when page is refreshed but not again afterwords when the view is changed for any other video or is accessed from the list.
How do I solve this? Also, please let me know if there's a better way of doing this.
Thanks.