How do I play a video in my app?

I want to play a video in my app, how do I do this?

I read that I cannot store videos in the DB, so let’s see the options for the following

  1. Video is stored in S3
  2. Youtube video

It is possible to render videos stored on S3. Here are a few things you’ll need to do:

  1. Setup an S3 bucket on AWS and upload your videos to the bucket

  2. Create a CC task that will generate a signed URL for your video. For more information on this, please see this resource
    Here is a snippet for signing the video url:

const AWS = require('aws-sdk');

const expireAfterSeconds = 60 * 60 * 24 * 60; // URL expires after 60 days
const s3 = new AWS.S3({
    accessKeyId: "Your Access Key ID",
    secretAccessKey: "Your Secret Access Key",
    region: "us-east-1"
});

const url = await s3.getSignedUrl('getObject', {
    Bucket: "Your Bucket Name",
    Key: "Your Video Key",
    Expires: expireAfterSeconds
});

return url;
  1. Call the CC task from your application Code so that the URL is generated.
varl url = return CloudCode.callTask("sign-url", {});
  1. Pass the signed URL to an HTML Bridge Component using the component.html().post('video',url); and use the following HTML attribute to render the video.
<video className="_playback" preload="auto" data-setup="{}" controls >
    <source  src="YOUR SIGNED URL HERE" type="YOUR VIDEO CONTENT TYPE HERE"/>
</video>