Private Video On Hls Or External Players
api.video recommends that you read Private Videos to ensure that you understand the concept of private videos before proceeding.
There are cases where you would want to use built-in players that are not api.video. We support private video delivery via other players other than our in-house. In this article you can find how to deliver private videos with HLS built-in player
HLS manifest for private videos
Playing your private video on an HLS player is as easy as just passing on the url we provide while you retrieve
for example, if you would like to play the video on HLS, we provide a ready made url for with the HLS manifest:
https://vod.api.video/vod/{video id}/token/{private token}/hls/manifest.m3u8
Serving private videos to HTML on Safari, Chrome and Firefox
You can use the video tag directly to play the video in Safari, for example:
Example of loading the manifest with hls.js on Safari:
<script src=><>
<script>
<
Source: GitHub
Test the manifest with hls.js demo
You can test and pass the manifest to this demo player that is provided by hls.js: https://hls-js.netlify.app/demo/
Serving private videos dynamically
In order to build a dynamically served private videos, you can leverage the /videos endpoint in order to get the url of the video and private token. For example the following steps are possible:
- Make a request to
/videos
endpoint
curl --request GET \
--url https://ws.api.video/videos/ABC \
--header 'accept: application/json' \
--header 'authorization: Basic ZYX='
- You will get the following response, where the private token in the url and you can get the manifest url from the
hls
field:
- All you have to do now is to get the
hls
url and pass it as a value to the HTML that will be generated by the server. We will handle the rest.
Private video delivery on iOS / tvOS native player (HLS)
You can serve the manifest directly into the native iOS player, you can find an example below.
Reference: Apple Developer docs
@IBAction
// Create an AVPlayer, passing it the HTTP Live Streaming URL.
let player = AVPlayer(url: url)
// Create a new AVPlayerViewController and pass it a reference to the player.
let controller = AVPlayerViewController()
controller.player = player
// Modally present the player and call the player's play() method when complete.
present(controller, animated: true) {
player.play()
}
}
Was this page helpful?