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
- Video is stored in S3
- Youtube video
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
It is possible to render videos stored on S3. Here are a few things you’ll need to do:
Setup an S3 bucket on AWS and upload your videos to the bucket
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;
varl url = return CloudCode.callTask("sign-url", {});
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>