Why is my video or videosphere not playing on mobile in A-Frame VR? - webvr

I have an A-Frame scene with a video or videosphere:
<a-scene>
<a-assets>
<video id="video" src="anothervideo.mp4></video>
</a-assets>
<a-video src="myvideo.mp4></a-video>
<a-videosphere src="#video></a-videosphere>
</a-scene>
When I test in iOS or Android, I just see a black screen. It works on desktop.

Speaking of leveraging Enter VR button, try:
<a-scene>
<a-assets>
<video id="video" src="anothervideo.mp4"></video>
</a-assets>
<a-video class="video" src="myvideo.mp4"></a-video>
<a-videosphere class="video" src="#video></a-videosphere>
</a-scene>
<script>
function playVideo () {
var els = document.querySelectorAll('.video')
Array.prototype.slice.call(els).forEach(function(el) {
el.components.material.material.map.image.play()
})
}
document.querySelector('.a-enter-vr-button').addEventListener('click', playVideo)
</script>

I struggled a bit with getting the Enter VR button to trigger the video (mayognaise's solution unfortunately didn't get me there), but eventually cobbled together this script that did the trick:
<a-scene>
<a-assets>
<video id="video" src="anothervideo.mp4"></video>
</a-assets>
<a-videosphere src="#video"></a-videosphere>
</a-scene>
<script type="text/javascript">
var scene = document.querySelector("a-scene");
var vid = document.getElementById("video");
if (scene.hasLoaded) {
run();
} else {
scene.addEventListener("loaded", run);
}
function run () {
scene.querySelector(".a-enter-vr-button").addEventListener("click", function(e){
console.log("VR Mode entered");
this.style.display = "none";
vid.play();
}, false);
}
</script>

Check https://aframe.io/faq/#why-does-my-video-not-play-on-mobile
iOS Safari documentation on video limitations: https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html#//apple_ref/doc/uid/TP40009523-CH5-SW1
Mobile browsers have limitations with displaying inline video. The 2D mobile web is not very suited for playing inline videos. Because of an iOS platform restriction in order to get inline video (with or without autoplay), we must:
Set the metatag (done by A-Frame).
Set the webkit-playsinline attribute to the video element. (On iOS 10, renamed to just playsinline)
Pin the webpage to the iOS homescreen.
And on certain Android devices or browsers:
User interaction to trigger the video (e.g., listen tap/click). You could leverage the click on the Enter VR button.
With all of these steps, you should provide instructions and UI to the user for the necessary steps to get mobile video playing (pin-to-homescreen, tap).
We will try to have a complete example out that addresses these cases.
They also document that only one video can play at a time, and there are restrictions on the format/codecs:
Safari on iOS supports low-complexity AAC audio, MP3 audio, AIF audio, WAVE audio, and baseline profile MPEG-4 video. Safari on the desktop (Mac OS X and Windows) supports all media supported by the installed version of QuickTime, including any installed third-party codecs.
iOS Safari has recently announced support for inline videos in the next version, but we'll have to wait to see how that plays out.

Related

getUserMedia return a rotated video on safari iOS

i need to stream a video over webrtc & play it on web page, it works properly on all desktop browser window & mac os. it works on android browsers too. but on safari iOS the video is rotated as landscape. it's rotated on both ( when capturig the video with iOS safari and when receiving the stream on chrome or safari desktop).
I tested it with the default basic getUserMedia example demo on webrtc site with safari iOS ans its the same issue. how can fix it or if any other solution please ?
Something that may be relevant that I've come across -
Requesting { width: 640, height: 480 } on iOS in portrait mode will return a camera MediaStream which is { width: 480, height: 640 }, and on orientation change the MediaStream flips its dimensions. Be careful around hardcoding the html elements width and height. Can cause warping. People should stick to known resolutions e.g those listed in en.wikipedia.org/wiki/Display_resolution. When you use an atypical resolution WebRTC spec states the browser will try emulate your desired feed. However this makes poor cross-browser code. If you want a consistent camera feed I would avoid this.
source:
getUserMedia (Selfie) Full Screen on Mobile

Youtube video expand icon disabled by default in webview for android platform and ipad's nativescript-angular

I am using native script-angular framework to develop android and ios applications. In my application I am loading youtube video using embed code in webview. The video was loading perfectly both android and ios phones and tablets, but the expand icon inside the youtube frame disabled by default in android devices and iPad's in ios platform. In ios phones, the youtube videos automatically expanded. How to solve the issue?
My Html code for loading youtube video inside webview
<WebView src='<Html><Body><iframe width="100%" height="300" src="https://www.youtube.com/embed/EXeTwQWrcwY" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></Body></Html>' width="100%" height="100%" ></WebView>
My ts code:
webviewLoaded(args)
{
const webview = args.object;
if (isAndroid) {
webview.android.getSettings().setJavaScriptEnabled(true);
webview.android.getSettings().setAppCacheEnabled(true);
webview.android.getSettings().setBuiltInZoomControls(true);
webview.android.getSettings().setSaveFormData(true);
}
}
Sample screen shot:

Having to click two play buttons to start the video in google drive

I have a situation here were I got to click two play buttons on an google drive video embed
This is my code for showing the video
<iframe src="https://drive.google.com/file/d/video_id/preview" width="960" height="540" allowfullscreen="true"></iframe>
After the video is loaded it displays a video thumbnail with play button and then when I click on it, it goes to another play button with a youtube like interface.
How can I get rid of this two play button? I just need one click then video should play after.
You may want to check this thread on how to play video from Drive using JavaScript. It stated that Google provides some GET-params like export and id with google-drive to give you the ability to insert an uploaded video into a HTML5-video-tag.
$("#play").click(function() {
$("#video")[0].play();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id="play" style="margin-top: 300px;">Play</button>
<video id="video" width="320" height="240" controls>
<source src="https://drive.google.com/uc?export=download&id=0B8-qLYDzDfCyRF9vOE9sWmx5YjA" type='video/mp4'>
Your browser does not support the video tag.
</video>
Check this link for additional information: Get Google drive video embed code using api

Remove middle play/pause botton from Vimeo video

I need to autoplay a Vimeo video inside my site. I removed the toolbar and all buttons from the video through my Vimeo Plus account but I can't figure out how to remove the middle Play/Pause button.
There is no setting for that on Vimeo and I can't find any hack to remove it because it is embedded inside an iframe with a different domain from my site.
<iframe src="https://player.vimeo.com/video/138579264" width="500"
height="275" frameborder="0" webkitallowfullscreen mozallowfullscreen
allowfullscreen></iframe>
So I want to know if there are some jquery player that can play a Vimeo video (https://vimeo.com/138579264) without that button.
You cannot remove the play button from our player, but since are a PRO member you can use a third-party player if you’d like: https://vimeo.com/s/adg.

VideoJS 'controls' causing video to not play correctly in Firefox (v18.0.1) on OSX (Mountain Lion)

I have VideoJS displaying a video in a modal window in a Wordpress website. I'm NOT using a videoJS plugin, I've loaded the latest VideoJS version to the home directory. The code for the video tag is in a separate non-Wordpress html file all on it's own.
The video IS working fine in Safari on the Mac, it's also working fine in Firefox on Windows. It is NOT working properly in Firefox on the Mac.
I have traced this issue back to it being caused by the 'controls' option in the tag. As soon as I change the options to 'autoplay' and take out 'controls', the video plays perfectly well in Firefox and Safari on the Mac.
More specifically it appears to be the small timer (showing how much video has played) on the skin's slider.
The skin in Firefox is different that the one in Safari. The one in Safari is BLACK and displays the time to the left and right of the slider at the bottom of the player. The one in Firefox is GREY and has the time in a small raised box above the slider at the bottom of the player. It is this raised box that seems to be causing an issue with the video playing in Firefox. The video is only playing slowly on a strip just above the slider and only to the height of the timer box.
I have tried putting:
<script>
_V_.ControlBar.prototype.options.components = {'playToggle':{}}
</script>
right under the call to
<script src="http://vjs.zencdn.net/c/video.js"></script>
in the head of the Wordpress page that has the modal window displaying the separate html page containing the code.
That did NOT work; both Safari and Firefox still show the controls at the bottom of the player.
I also tried adding:
.vjs-default-skin .vjs-time-controls {display: none !important;}
to my WP theme's stylesheet. That did NOT work either.
QUESTION 1: Why is Firefox using a different skin for VideoJS than Safari? If I can get the same controller for Firefox (ie one without the raised time code box) then the video may play normally.
QUESTION 2: How can I limit the controls to show only the large centred play button without showing the controls at the bottom of the player? Again, not having the raised time code box may make the video display normally in Firefox.
QUESTION 3: All this came about because I discovered iPhone and iPad do not play videos with the autoplay setting. I had originally set the option for autoplay in the tag without 'controls', but because it wasn't working in iPad (just getting a black background to the video) I took out 'autoplay' and added the 'controls'. And that's when I noticed the problem in Firefox. So if I can't fix the issue with having controls in Firefox and it not working, is there a way to get round the black screen issue on the iPad and using 'autoplay' for Firefox without controls?
Please let me know if there's any other information you need.
You shouldn't need the code as it's all working; the problem only arises in Firefox on the Mac when I add 'controls' to the tag. And I'm sure this can be fixed by using a different skin or getting rid of the controls at the bottom of the video (well, I'm hoping that will fix it!).
BTW I'm using this in the head of my WP template
<link href="http://vjs.zencdn.net/4.0/video-js.css" rel="stylesheet">
<script src="http://vjs.zencdn.net/4.0/video.js"></script>
Oh, and Firefox is not falling back to the Flash Flowplayer, it's definitely playing the ogg file in the HTML5 video tag.
ctagney, thanks for taking the time to respond.
Question 1
Hmm, strange.
I have this in the header at the moment:
<link href="http://vjs.zencdn.net/4.0/video-js.css" rel="stylesheet">
<script src="http://vjs.zencdn.net/4.0/video.js"></script>
This is the code I have in the html page (I've replaced actual domain with ... as I don't want links to the site --- you can see the video on www. horizonyachtsgrenada .com/ new-yacht-sales-grenada/ at the top of the right-hand side bar:
<div style="margin:0; Padding:0;">
<video id="salesvideo" class="video-js vjs-default-skin" preload="auto" controls width="540" height="320"
poster="http://.../videos/horizon-dream-makers-splash.jpg"
data-setup="{}">
<source src="http://.../video/HORIZON_FINAL_HD.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' />
<source src="http://.../video/HORIZON_FINAL_HD.ogv" type='video/ogg; codecs="theora, vorbis"' />
<source src="http://.../video/HORIZON_FINAL_HD.webm" type='video/webm; codecs="vp8, vorbis"' />
<!-- Flash Fallback. Use any flash video player here. Make sure to keep the vjs-flash-fallback class. -->
<object id="flash_fallback_1" class="vjs-flash-fallback" width="540" height="320" type="application/x-shockwave-flash" data="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf">
<param name="movie" value="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf" />
<param name="allowfullscreen" value="true" />
<param name="flashvars" value='config={"playlist":[http://.../videos/horizon-dream-makers-splash.jpg", {"url": "http://.../video/HORIZON_FINAL_HD.mp4","autoPlay":true,"autoBuffering":true}]}' />
<!-- Image Fallback. Typically the same as the poster image. -->
<img src="http://.../videos/horizon-dream-makers-splash.jpg" width="540" height="320" alt="Poster Image" title="No video playback capabilities." />
</object>
</video>
</div>
Any ideas why it's not using the video.js?
Question 2
I've added that code to the page now, so hopefully once it's picking up video.js it will pick this up. I assume I won't need 'controls' in the video tag for this to work, is that correct?
Question 3
So, if I'm understanding your link correctly, I'm right in changing it from autoplay to having controls for it to work on the iPad and iPhone.
New issue:
It's not working in Chrome even though there is a webm version of the video! I'm beginning to go greyer ... just want the video to work now!! :(
Any help much appreciated.
Cheers,
Tracy
EDIT: BTW the video does play on Safari, Firefox, and Chrome on a different site (different server, different video code) so it's not the video itself causing an issue.
The players you're describing in firefox and safari sound like the native video players for each browser. In other words, you're not actually using video.js.
Question 1
Once you get it working, you'll notice that the players should look identical to one another in Safari and Firefox. Without seeing your code it's hard to say why your video.js player isn't getting initialized, but you need to do one of the following:
Include a data-setup='' tag in your video element, which you can use to specify options via a JSON value.
Have a separate script that calls _V_("video id", {}) once the page has loaded.
I recommend you use the second option since you have some additional setup to handle (see: below)
Question 2
The big play button you want is automatically hidden when controls are turned off, so you should just call it's show() method once the video player has been initialized.
<script>
_V_("example", {}, function() { this.bigPlayButton.show(); });
</script>
See the following for a working example.
http://jsbin.com/ijipag/2/edit
Question 3
See Can you autoplay HTML5 videos on the iPad?
The issue was I didn't include the call to the video.js
<link href="http://vjs.zencdn.net/4.0/video-js.css" rel="stylesheet">
<script src="http://vjs.zencdn.net/4.0/video.js"></script>
in the separate (non-WP) html page that's shown in the modal (FancyBox iframe) window. I've now included that and it's successfully calling the video.js and showing the big play button without the bottom controls in Safari and Firefox.
It's still NOT working in Chrome. In Chrome, when you click the play button it's just showing the poster image and the spinning loading gif.
UPDATE: Got it working in Chrome by moving :
<source src="http://www.horizonmotoryachts.com/video/HORIZON_FINAL_HD.webm" type='video/webm; codecs="vp8, vorbis"' />
above the calls to the mpeg4 and ogg files.
Tested on Firefox and Safari on Mac and its still working.

Resources