Comments (8)
@nathanagez I actually realised that for signed urls the right way of passing source and token is as follows:
<VideoPlayer autoplay controls sources={[{ src: 'https://xxxxxxxx.cloudfront.net/{path}/{path.m3u8}{token}', type: 'application/x-mpegURL' }]} token={token} />
However, now I am getting the following error:
VIDEOJS: WARN: Problem encountered with playlist 0-http://localhost:3000/undefined. Trying again since it is the only playlist.
@pedramp20 token have to be append to each requests, I'll provide you the correct snippet of code but I'm not in front of my computer FTM.
I'll ping you ASAP.
from amplify-video.
I resolved the issue using React Player. if anyone else is having problem with playing HLS with credentials. here is how to play it with react player:
<ReactPlayer
url={source} //this your source url WITHOUT APPENDED TOKEN: https://xxxxxxxx.cloudfront.net/{path}/{path.m3u8}
controls={true}
config={{
file: {
hlsOptions: {
xhrSetup: function xhrSetup(xhr, url) {
xhr.setRequestHeader(
"Access-Control-Allow-Headers",
"Content-Type, Accept, X-Requested-With"
);
xhr.setRequestHeader(
"Access-Control-Allow-Origin",
"*"
);
xhr.setRequestHeader(
"Access-Control-Allow-Credentials",
"true"
);
xhr.open('GET', url + token); // this is your token: ?Policy=foo&Key-Pair-Id=bar&Signature=foobar
}
}
}
}}
/>
from amplify-video.
https://gist.github.com/wizage/1523dd1f6928e0d852042e6adbaf54cd
Yes but instead of using Hls
use Vhs
since Hls
is deprecated.
import React from 'react';
import videojs from 'video.js';
import 'video.js/dist/video-js.css';
export default class VideoPlayer extends React.Component {
componentDidMount() {
videojs.Vhs.xhr.beforeRequest = (function (options) {
options.uri = `${options.uri}${this.props.token}`;
return options;
}).bind(this);
this.player = videojs(this.videoNode, this.props);
}
componentWillUnmount() {
if (this.player) {
this.player.dispose();
}
}
render() {
return (
<div>
<div data-vjs-player>
<video ref={(node) => { this.videoNode = node; }} className="video-js"></video>
</div>
</div>
);
}
}
from amplify-video.
Hi @pedramp20, please can you provide the VideoPlayer component source code ?
from amplify-video.
@nathanagez I actually realised that for signed urls the right way of passing source and token is as follows:
<VideoPlayer
autoplay
controls
sources={[{
src: 'https://xxxxxxxx.cloudfront.net/{path}/{path.m3u8}',
type: 'application/x-mpegURL'
}]}
token={token}
/>
However, now I am getting the following error:
VIDEOJS: WARN: Problem encountered with playlist 0-http://localhost:3000/undefined. Trying again since it is the only playlist.
Here is the videoplayer component code:
import React from 'react';
import videojs from 'video.js';
import 'video.js/dist/video-js.css';
export default class VideoPlayer extends React.Component {
componentDidMount() {
this.player = videojs(this.videoNode, this.props);
}
componentWillUnmount() {
if (this.player) {
this.player.dispose();
}
}
render() {
return (
<div>
<div data-vjs-player>
<video ref={(node) => { this.videoNode = node; }} className="video-js"></video>
</div>
</div>
);
}
}
Ps. Since video setup got stuck in adding video js to package.json, I manually added the package and called setup again.
from amplify-video.
@nathanagez do you mean this? https://gist.github.com/wizage/1523dd1f6928e0d852042e6adbaf54cd
It didn't work for me
from amplify-video.
@nathanagez I am having problem playing videos using both react player and video js on iOS (Safari). Is there a specific config that needs to be set? I have already tried this but didn't work
{
html5: {
hls: {
overrideNative: overrideNative
},
nativeVideoTracks: !overrideNative,
nativeAudioTracks: !overrideNative,
nativeTextTracks: !overrideNative
}
}
from amplify-video.
from amplify-video.
Related Issues (20)
- Getting 403 Forbidden when trying to upload video to the input s3 bucket as an authenticated user HOT 9
- Output bucket not granting Public Read permission when filename contains spaces HOT 1
- Video object lost when VodAsset json is parsed into VodAsset object HOT 1
- Deployment Failed when Deploying from Admin UI After Adding Amplify Video to Schema HOT 4
- HLS Video with Credentials (signed url) cannot be played on iOS/Safari HOT 11
- Surface Ivs Start/Stop channel events to a SNS queue
- Audio-Only Pipeline Guide in Wiki Fails to Output Audio HLS
- Cannot Add New Environment with Video Plugin
- Can not push to amplify when updating to v3.9.2 HOT 1
- Template error: instance of Fn::GetAtt references undefined resource videoResource HOT 2
- Provide Audio-On-Demand (AOD) option
- Failed compiling GraphQL schema: Your GraphQL Schema is using "@connection" directive from an older version of the GraphQL Transformer. HOT 3
- Adding amplify video with a Signed URL option fails because of permissions (even with an IAM user with Admin access)
- React video code for both Dash and HLS? HOT 1
- `AccessDeniedException` when invoking lambda function to convert video from input to output bucket HOT 1
- amplify video add command not found HOT 1
- Amplify will not Push after adding Video
- Generated GraphQL schema contains @connection HOT 1
- amplify video add (video on demand) no longer working with away amplify updated cli. HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amplify-video.