Play HTML5 videos forward and backward on hover - html5-video

I've been trying for days to get a specific behaviour on the homepage of my personal website. But I didn't find any good solution yet. Can someone help me please :-)
I have a homepage with a grid of short videos with different durations. I want each of them to play completely on mouse hover. On second hover most should replay normally, but some should play backward.
I read that playing videos backward was not good in terms of performance because native browser players were not meant for that. So I searched for an alternative and came to the following idea:
Double the duration of those "special" videos so they integrate their forward sequence (1-2-3) and backward sequence (3-2-1) in the same file. On first hover, the video would play its first half, and after that only, on second hover it would play the second half.
Here is a JSfiddle where I put all elements for testing… but I'm currently stuck with my poor JS skills.
HTML:
<video class="forward-backward">
<source src="http://tacco.fr/divers/forward-backward.mp4" type="video/mp4">
<source src="http://tacco.fr/divers/forward-backward.webm" type="video/webm">
</video>
jQuery:
var figure = $("video").mouseover(hoverVideo);
function hoverVideo() {
$(this).get(0).play();
};
It may be a very bad idea in terms of performance (because filesizes are bigger to load), so I'm really open for any others.
Don't hesitate to ask if you have any question.
Thank you very much :-)
BTW: no more than 5 videos should play at the same time… I don't know how to do that…

I ran into this problem. The best solution I can think of is to use a video editor and reverse the video files themselves. Then you create two video elements, one with the forward video as the source and one with the reverse video as the source. Using javascript, you can then show the correct video (and hide the other one) depending on whether you want the video to be playing forward or backwards. Does that help?

Related

using VideoJS VAST plugin without video content

I want to display ads with VAST ad tag and with a HTML5 player. I'm currently trying to use videoJS with Vast Ads Plugin and I'm noticing I can't get the videoJS player to work without having a video content (video element with a src attribute for the video content).
Does anyone know a simple way to use a video player for just ads from VAST, and without video content? Google IMA3 SDK allows that, but I'm now looking for video plugins to cover IE use case (which Google IMA3 SDK does not cover).
Thank you!
There is a dirty way to do this. You can get the ad video url from the plugin that already parsed by it. Then just paste as src to video tag.
If the player you are using support only running pre-roll, that's obviously the best choice. Since that's likely not the case, I would recommend creating a small 1 second long black video MP4 and setting it as the content, with all video controls disabled. This was the lowest friction solution for me, as I didn't need to ask the player anything special of the player. The pre-roll plays, and the user briefly sees black at the end, which may not really be noticed.

Inline video in mobile Safari?

I've been attempting to find a method for playing video inline in mobile safari for awhile now.
I know this is possible and has been achieved (see link)-
http://www.raptmedia.com/project/philips-designed-play-drives-mobile-video-engagement
However, I am unable to determine how this is done. I've tried manipulating iframes but this alone doesn't seem to have any impact.
I've included a js player for cross browser compatibility and used it within an iframe, no luck in mobile:
<div class="vid"> <video id="vid01" class="video-js vjs-default-skin" controls="controls" preload="none" width="600px" height="600px">
<source src="video.mp4" type='video/mp4'/> <source src="video.webm" type='video/webm'/>
<source src="video.ogg" type='video/ogg'/> <track kind="captions" srclang="en" label="English" />
</video> <script> var myPlayer = _V_("vid01"); ` </script>` </div>
I know this is an old question, but it ranks high in my Google search and I can at least answer the question posed above, so I'll add this in case other people come across it: why does it work on that particular page?
I looked at it, and it doesn't really play inline video. On my iPhone, it preloads a ton of JPG frames and then "plays" them like a movie, while playing an mp3 audio track behind it. So they are just faking it, basically. Still not able to play the video inline on the phone.
The only solution I know is based on the drawImage function of the canvas tag... I spotted the basics here on SO but there's some fun left for the reader :D, in a few words, You hide and play the video and at the right freq You render the current frame into a canvas, some attention is needed for the audio sync. It works better than expected.
Here is a basic sample, and here another one where I try to apply some webkit based filters.
Hope it helps, have fun!
You can use something like this library to make it work: https://github.com/bfred-it/iphone-inline-video
It basically uses an audio tag to drive the video by seeking to the current time, so you can have the frames updated without having to play the video.
The good news is that iOS 10 will support this, so no more hacks are going to be needed: https://developer.apple.com/library/prerelease/content/releasenotes/General/WhatsNewInSafari/Articles/Safari_10_0.html#//apple_ref/doc/uid/TP40014305-CH11-DontLinkElementID_12

YouTube iFrame API quality parameter "vq" bug - video playback with black screen

There seems to be a huge issue with the iframe url parameter "vq" (in this case "vq=hd720").
If you use this paraneter, the video screen in the flash player turns black.
This example URL worked until today:
http://www.youtube.com/embed/dFVDJlM6zLY?vq=hd720
(feel free to replace the example YouTube ID)
Now, this example works only without the "vq" parameter (vq=hd720):
http://www.youtube.com/embed/dFVDJlM6zLY
The problem is, that we delivered this YouTube iframe in a lot of websites for a lot of clients and it worked quite well for month (years?). Now every single site has black youtube videos!!!
Does anyone know if this parameter was depricated?
Was there a new YouTube API release today?
The parameter was already discussed and recommended in diffrent forums:
e.g. Force youtube embed to start in 720p
Any ideas how to force Google (YouTube) to solve this problem?
It seems that the only way out of this (currently) is to remove the vq parameter or set it to auto. This seems like a widespread problem though, that has occurred very recently. You may wish to star this issue at google make them take notice:
https://code.google.com/p/gdata-issues/issues/detail?id=6009
I was having a similar issue but when I tried to force an embeded youtube video to play in HD at a dimension smaller than the HD resolution.
I was able to get around the "black screen" HD issue by using the old embed code.
If you set the video size to the highest resolution you can then use vq=hd720 parameter and set the video width and height to a lower resolution
<object width="1280" height="720"><param name="movie" value="//www.youtube.com/v/VIDEO_ID?hl=en_US&version=3&rel=0&vq=hd720"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="//www.youtube.com/v/kyilUYoxcww?hl=en_US&version=3&rel=0" type="application/x-shockwave-flash" width="560" height="315" allowscriptaccess="always" allowfullscreen="true"></embed></object>
Hope this helps!
Just had this exact problem. Found changing it to vq=auto works in the code. But on the videos we're working with it's coming out at a slightly lower quality than we'd like.
Nevertheless, this at least removes the blackout.
What are your 3d settings set to? Here's what I've noticed...
1) Taking away the vq=hd setting works.
2) Turning the 3D setting on the video player ON (or sometimes OFF the ON again) makes the
video work.
3) Curious about number 2, I went to the video settings on the video (the admin settings) and changed the 3D settings under Advanced. I changed it from "Disable 3D for this video" to "Please make this video 3D." For some reason this works -- the vq code is back to working the way it should.
HOWEVER I don't know if I would recommend doing this! The reason I set all my videos to "Disable 3D for this video" in the first place was because if I left on on the on the default "No Preference," it often caused glitches in the video.
Has YouTube changed anything with the 3D settings recently? I think thay may have but am not certain.

Video.js changing source and seeking simultaneously

I am trying to build a site using video.js to view videos. We need to switch videos while maintaining the currentTime value from the old video. The way I have it working right now is using the loadedmetadata event to set currentTime. The problem I am seeing with this is that the first frame of the video gets shown momentarily while the player seeks to the right time. I am new to JS programming so perhaps I am doing something wrong but I do not see anything in the docs that can help me overcome this. I am trying to render H.264/mp4 videos in Chrome. Thanks!
Changing the preload setting to 'metadata' might help this in the browsers that support that setting.
preload="metadata"
Then it supposedly should only load the metadata and trigger the loadedmetadata event, and not show the first frame. That is unless providing any new src forces preloading, and I'm not sure off the top of my head.
HTML5 video doesn't give us a lot of options around seamless switching videos unfortunately. The media source API proposal from Google/Microsoft/Netflix aims to fix this. http://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.html
You could try this:
https://bitbucket.org/felixschwarz/videojs-hdtoggle/
As seen here on the old videoJS-Forum I think you might have to declare preload="auto".
In the linked forum-threat there are also some changes I made documented.

Can HTML5 track element be used for *live* subtitles?

I am planning to build a system to broadcast public events (trials, meetings, conferences).
A key request will be the insertion of live subtitles to the A/V stream.
The subtitles will be "live" since they will be produced by an operator while the event will happen.
I suppose the HTML5 "track" element is not yet implemented by any of the major browsers, but: can I expect to eventually use it for live subtitles? Will I be able to inject the subtitle to the page while the stream is playing?
Please Look at the following links. Looking at the link i am having to believe it should be possible as they are using Js to show subtitles
http://www.storiesinflight.com/js_videosub/
http://cuepoint.org/
You may also consider http://mozillapopcorn.org/ which is to show content on timing of the video. So technically u can use this with ajax to show/stream subtitles
There are HTML5 video JS libs that support subtitles (eg: VideoJS supports the .srt format, there are several easily Google-able others), however to the best of my knowledge none of them support streaming subtitles.
I think you may have to build your own solution for this. If I were to do it, I'd probably try doing something with Socket.IO's broadcast functionality that can push data out to all connected clients at once, and have your client-side JS listen for new subtitle events and render them on screen as they come in. You can use plain ol' CSS to overlay the text over the HTML5 video.