1

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.

2
  • Can you create a simple Plnkr.co or Codepen example and will make it work for you? Commented Sep 2, 2015 at 11:45
  • I'm not sure if I can do that since the data is coming from API and there are so many linked files. But I'll try to make one. Commented Sep 2, 2015 at 11:46

1 Answer 1

2

It's solved now. I've turned off caching and started using local jwplayer js rather than one from CDN. It's all working fine now.

Thank you all.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.