Need html5 video player to end on last frame.

Hi!
I'm using the native html5 video player in WordPress. I need the video to stop on the last frame.
I found some code to do it, but it's not working. I think I may need to swap out some more dollar signs in the function, but I'm not sure.

Page is here:

http://sandbox.intrepidrealist.com/eqogo/alicias-test-page/

Here's my script:

<script>
			(function(jQuery) {
			jQuery(document).ready(function() {
				var $videos = $('.play_once video');
		
				$videos.each(function() {
					var $video = $(this)[0];
		
					$video.removeAttr('loop');
		
					$video.addEventListener('loadedmetadata', function() {
						var pause_at = $video.duration - 0.5,
							interval;
		
						$video.addEventListener('playing', function() {
							interval = setInterval(function() {
								if ($video.currentTime >= pause_at) {
									$video.pause();
								}
							}, 450);
						}, false);
					});
				});
			});
		})(jQuery);
		</script>

Open in new window

LVL 9
Alicia St RoseOwner & Principle Developer/DesignerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
Why do you want it to stop on the last frame?
0
Alicia St RoseOwner & Principle Developer/DesignerAuthor Commented:
It's acting as a short animation to the right and then I'm going to fade in some images to the left with CSS animations when the video is done.

You can see it here. It plays automatically and then disappears. :(

http://sandbox.intrepidrealist.com/eqogo/alicias-test-page/
0
Julian HansenCommented:
Normally a video stops and shows its last frame. I copied your <video> element into a sample page (you can see it here http://www.marcorpsa.com/ee/t3098.html) as you can see when it is done it shows the last frame.

Something on your page is clearing that.

If I copy you page and remove the media element library then the last frame is displayed - so something in that library is clearing the video.

What is the library doing for you?
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Alicia St RoseOwner & Principle Developer/DesignerAuthor Commented:
Okay, here is my greeness showing. I don't even know what the media  element library is. I'm using Flexslider and intend to add this video as a slide then fade in two images to the right using CSS animations. I've got this going with static images, (see here) not yet with video. So, I'm not sure it will work. Could the Flexslider be the problem?
0
Julian HansenCommented:
No it is not flexslider

This is the script that is the problem

<script type='text/javascript' src='http://sandbox.intrepidrealist.com/eqogo/wp-includes/js/mediaelement/mediaelement-and-player.min.js?ver=4.2.6-78496d1'></script>

Something in that is reseting the video on end - it is quite a large file (the uncompressed version) and trying to figure out where exactly it is doing it will take some time - which I don't have at the moment.

My feeling is you should try and stop it from doing what it is doing rather than trying to hack around pausing the video - which has a lot that can go wrong.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Alicia St RoseOwner & Principle Developer/DesignerAuthor Commented:
THANK YOU!!

It was a script from a plugin. My video works perfectly now!!
0
Julian HansenCommented:
You are welcome.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.