In the documentation for ReactVR for VideoPano
it demonstrates pointing to a video in the code base.
Is it possible to link to an external link (aka Youtube)?
So instead of video.mp4, it would link to https://www.youtube.com/watch?v=hkgYIr_LWPw&index=1&list=PL-BE7kqSgbEj44peyt5BmLK63kbDp7Rhu
let videoUrl = 'video.webm';
const supportedFormats = NativeModules.VideoModule.supportedFormats;
for (let i = 0; i < supportedFormats.length; i++) {
if (supportedFormats[i] === 'mp4') {
videoUrl = 'video.mp4';
}
}
the rest of the code looks like this.
class WelcomeToVR extends React.Component {
constructor(props) {
super(props);
this.state = {
playerState: new MediaPlayerState({autoPlay: true, muted: true}), // init with muted, autoPlay
};
}
render() {
return (
<View>
<VideoPano
playerState={this.state.playerState}
source={asset(videoUrl, {layout: 'SPHERE'})}
/>
<VideoControl
style={{
height: 0.2,
width: 4,
layoutOrigin: [0.5, 0.5, 0],
transform: [{translate: [0, 0, -4]}],
}}
playerState={this.state.playerState}
Solution 1 (didn't work)
You could try to use an embed the video: https://www.youtube.com/embed/hkgYIr_LWPw. This will give you just the video without other content.
If you need a embedded video, just left click on the video and choose "embed this video" and change the source of your
<VideoPano playerState={this.state.playerState} source={videoUrl} />
Not sure if this could wok because the source code is again HTML, JS and CSS. But you could give it a try. And it didn't work
Solution 2
Download the video using a YouTube downloader1 or other one and use that.
<VideoPano playerState={this.state.playerState}
source={ asset(videoUrl, { layout: 'SPHERE' }) } />
1 No publicity for that tool, just the first result I've found on Google.
YouTube intentionally chooses to obfuscate the direct links to their video files. Linking the embedded player isn't a solution since that thing's a mini web app with streaming logic, not an actual video file.
There's a pretty good write-up on how you could get around that here How do all of these “Save video from YouTube” services work? (probably against their Terms and Conditions though).
It is possible, however, to link to an external video URL, here's how:
Pick a random 3D 360 YouTube video, like this one
Download it, I used savefrom.net but there are many others and host it somewhere http://YOURDOMAIN/YOURVIDEO.mp4
Render a <VideoPano /> in your scene/view
<VideoPano source={{
uri: 'http://YOURDOMAIN/YOURVIDEO.mp4',
stereo: 'BOTTOM_TOP_3D' // this is specific to YouTube 3D videos
}} />
https://facebook.github.io/react-vr/docs/videopano.html
Related
I have embedded a youtube video in my HTML page. Since the video screen size is too small, the hover effect on the progress bar is getting cropped.
How can I stop this hover effect on the progress bar?
There is no option to disable the thumbnail preview in YouTube's native embed players. But you can disable the player controls altogether by appending ?controls=0 to the embed URL.
Here is an example, <iframe width='340' height='200' src="https://www.youtube.com/embed/MpGLUVbqoYQ?controls=0"></iframe>
the previous comment has it right. if youre using the API with javascript it might be best to use it like this:
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '390',
width: '640',
videoId: 'videoId',
playerVars: {
'controls': 0
}
});
}
Could somebody tell me how to remove youtube suggestion thumbnails on embedded video.
I am using iframe api. It feel like it should be easy. But i just can't find anything on google on how to do it.
tag.src = "https://www.youtube.com/iframe_api";
function initPLayer(playerDivId){
return new YT.Player(playerDivId, {
height: '390',
width: '640',
videoId: '4EDMR75lrKY',
events: {
'onReady': onPlayerReady1,
'onStateChange': onPlayerStateChangePlayer1
}
});
}
Thanks for help!
I knew it was obvious :P.
There is thing called player parameters.
Rel:
This parameter indicates whether the player should show related videos when playback of the initial video ends. Supported values are 0 and 1. The default value is 1.
Video autoplay (including YouTubes autoplay=1) does not work on iOS Safari. That is thourougly documented by both Apple and a large number of blog posts.
This does however cause a problem with using custom controls for YouTube videos, that I can't find a definate yes/no answer for anywhere.
If I used a simple HTML5 video tag there would be no issue - but I would really rather not have to encode all the videos for all the different platforms.
What I need to accomplish is:
A cover image is shown (flat PNG with a play icon on top).
The user clicks the cover image, the image is replaced by a YouTube video that starts playing.
This is not autoplay from the users perspective, since it is initiated by a click. However on all non-Flash devices YouTube embeds are displayed in an iframe, causing the video to effectively be loaded and autoplayed (or at least, I think so).
Does anyone know of any workarounds for this problem?
This snippet illustrates the problem. It works in e.g. FireFox, but on iOS Safari it simple shows the loading indicator and then ends in a black screen.
If I add the "apple-mobile-web-app-capable" meta tag and fire up the site from the home screen, the videos play correctly.
<div id="movieContainer" style="width: 768px; height: 432px; border: 1px solid #cccccc;">Initializing player API...</div>
<div id="status">Initializing player API...</div>
<button onclick="player.playVideo();">Play</button>
<script>
// Load the IFrame Player API code asynchronously.
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var playerAPIIsLoaded = false;
function onYouTubePlayerAPIReady()
{
playerAPIIsLoaded = true;
document.getElementById("status").innerHTML = "Player API initialized!";
}
var player = null;
function initMovie()
{
document.getElementById("status").innerHTML = "Loading video..."
player = new YT.Player(
'movieContainer',
{
height: '432'
, width: '768'
, playerVars: { 'autoplay': 0, 'controls': 2, 'rel': 0, 'showinfo': 0 }
, videoId: 'MwnZr4VJQPQ'
, events: { 'onReady': function (event) { document.getElementById("status").innerHTML = "Video loaded!";/*event.target.playVideo();*/ } }
}
);
}
window.onload = initMovie;
</script>
With IFrame API, whether a video is played with html5 container or flash container depends on a lot of factors. I'm wondering: is it possible to set some parameter or call a function to force the player to be flash(or html5)?
besides, rel=0 seems not work in Iframe API, when I set it to 0, the related videos are still shown, is there something wrong with my code? thanks!
player = new YT.Player('player', {
height: '300', //720
width: '400', //1280
videoId: 'S2Rgr6yuuXQ',
playerVars: { 'rel': 0 }, // or rel: 0, rel: '0', all don't work
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange,
'onError': onErrorDetected,
'onPlaybackQualityChange': onQualityChange
}
});
I think that the iframe option does not include a parameter to select html5 or flash option , because the iframe API uses the best option automatically.
you can try to specify to use HTML5 if available:
Force HTML5 youtube video
YouTube video in HTML5
and you can use the SWFObject option to use only the flash player in the client (if the client supports flash ..)
Using playerVars: { html5: 1 } loads an iframe with a html5=1 attribute in the src, similar to Force HTML5 youtube video.
Replace
playerVars: { 'rel': 0 }
with
playerVars: { 'rel': '0' }
I have seen this script to auto-mute video's from youtube embedded on a site:
How do I automatically play a Youtube video (IFrame API) muted?
The code is available on fiddle:
http://jsfiddle.net/9RjzU/3/
However I would like to know what to add to this code to prevent related videos appearing?
Thanks
Azzam
In your situation, all that is needed is to add 'rel': 0 to the PlayerVars parameters, like so:
function onYouTubePlayerAPIReady() {
player = new YT.Player('player', {
playerVars: {
'autoplay': 1,
'controls': 1,
'autohide': 1,
'wmode': 'opaque',
'rel': 0
},
videoId: 'JW5meKfy3fY',
events: { 'onReady': onPlayerReady }
});
}
You might also be interested in the full list of parameters available for the YouTube iframe API, found here: https://developers.google.com/youtube/player_parameters#Parameters