Auto-upload uploaded videos to JWPlayer dashboard

Just wanted to post a very tiny how-to on uploading videos from a file-section to JW because I thought it might be a difficult task and even wanted to hire someone to do it, turns out it isn’t.

If you want to auto-upload videos to a JWPlayer Pro or developer account you can do that via a file.create:after hook within a regular file-section.

1st: Get your API credentials from the JWPlayer dashboard
2nd: Download and install the JWPlayer-Platform GitHub - jwplayer/jwplatform-php: PHP library for the JW Platform API
3rd: Paste the code stated in the Upload section on GitHub into a file.create:after hook inside your config file. Don’t forget to use try{} and catch{}
4th: Adjust the code using your credentials or an if file type is video
5th: Use $file->url() for the target url to your video file
6th: To get the JWPlayer video-id of the uploaded video use $videoID = $upload_response['media']['key'] to get the video-id from the response
7th: You can then construct the full url to the uploaded video using $remoteUrl = '' . $videoID . '.' . $file->extension() (keep in mind that the jwplatform path could change sometime if they decide to though, I guess, so hardcoding it is a bit of a risk)
8th: In your file template create a hidden field ‘videoUrl’ or something
9th: Populate the hidden field with the constructed url

   'videoUrl' => $remoteUrl

10th: Upload a video to the panel’s file-section
11th: Use the constructed videoUrl to create your frontend players

(In the network tab selecting file in your browsers developer tools you should see the full JW response)

The maximum file size of the uploaded video is determined by the settings in your hosting provider’s php.ini settings. For instance:


Hope that helps anyone, feel free to correct anything.

(Uploading a video to the Vimeo dashboard has a similar approach except with Vimeo you specifically need to apply for API access.)

1 Like