Step 2. Define video assets and token policies
After the solution’s CloudFormation stack is deployed, you can define your video assets details (if you haven’t provided them as CloudFormation stack input) by following the next steps:
-
After the solution has deployed, navigate to the DynamoDB console and Explore items page under Tables.
-
Select the table which name starts with following string: [Stack Name]-ApiDemoTable.
-
Under Items returned section you can add and modify the list of items which detail original video asset’s hostname with URL path and a token policy for that content. In the demo web page deployed in the solution, two video assets are requested by the use of their ID corresponding to the entries in this table. To successfully start a video playback on the website, make sure that table entry with the ID that equals to 1, references HLS stream and the other one with ID of 2, to DASH stream.
-
To edit the details of the HLS stream, select an item with ID that equals to 1 and select Action, then choose Edit Item.
-
Make sure that the endpoint_hostname fields and url_path are filled in correctly as instructed in the previous HLS Stream parameter description.
-
Expand token_policy property and modify the values of predefined properties which determine the parameters of the output token that will be created for this specific video asset.
-
Choose Save changes to submit the changes.
-
For DASH stream, repeat steps from 4 to 7.
-
Test if API Gateway returns a valid playback URL with a secure token. Record the distribution hostname fronting API Gateway. You can find it in the launched stack output tab with a key value starting with ApiEndpointsDistributionDomainName. Using a utility tool like curl, make an HTTP request as follows:
For HLS:
curl [ApiEndpointDistributionDomainName]/tokengenerate?id=1
For DASH:
curl [ApiEndpointDistributionDomainName]/tokengenerate?id=2
In response, you should see the playback URL comprised of video asset hostname and URL path, with the secure token added at the beginning of the original URL path.