video player height

As shown on the left side of the below image, the height of video players take too much space.

Question: How can I make them to show like on the right side?

Do I need javascript to resize it when user clciks on play button so that it height will increase to 400, for example to show the video?videos
<span class="blue18">Demo list:</span></br>
	<video width="400" controls>
		<source src="./resources/KaiserDatauploadETL.mp4" type="video/mp4">
			Your browser does not support HTML5 video.
	</video>
	<br/>
                    
	<video width="400" controls>
		<source src="./resources/1_OverView_Feb26.mp4" type="video/mp4">
			Your browser does not support HTML5 video.
	</video>

Open in new window

LVL 34
Mike EghtebasDatabase and Application DeveloperAsked:
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.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
<span class="blue18">Demo list:</span></br>
      <video width="400" height="100" controls>
            <source src="./resources/KaiserDatauploadETL.mp4" type="video/mp4">
                  Your browser does not support HTML5 video.
      </video>
      <br/>
                   
      <video width="400" height="100" controls>
            <source src="./resources/1_OverView_Feb26.mp4" type="video/mp4">
                  Your browser does not support HTML5 video.
      </video>

?
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
<video width="400" height="100" controls>

makes it smaller based on 100. Then using aspect ratio reduces width to something like 75. On play, it starts playing in 57 x 100 box which is no good.

I think, there ought to be some javascript involved to change width to 400 onclick event (never mind height). Height gets calculated automatically.

This java script also has to change to original size when the video control loses focus.

I do not have display video player at all if I can get is started via some hyperlink.

So, we don't have a solution to this point.

Mike
Dave BaldwinFixer of ProblemsCommented:
I don't believe that JavaScript can do that.  You would have to program that in the video files language like 'mp4' or 'Flash'.  That is because the 'onclick' is not seen by the normal browser JavaScript but only by the video code.
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!

Julian HansenCommented:
It is very possible with this bit of jQuery
<script src="http://code.jquery.com/jquery.js"></script>
<script>
$(function() {
  $('video').on('play', function (e) {
    $(this).css({height: '400px'});
  });
});
</script>

Open in new window


Working sample here
Julian HansenCommented:
Here is a better version - with the following video element the width is removed and we have added a custom data attribute (data-height) that specifies how much we want the height to be when playing.
    <video height="100" controls data-height="500">
      <source src="http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/mp4">
      Your browser does not support HTML5 video.
    </video>

Open in new window

Here is the jQuery to set the custom height based on the data-height attribute and to restore it to the original height when finished playing
jQuery
<script>
$(function() {
  $('video').on('play', function (e) {
    // SAVE THE CURRENT HEIGHT
    var saved = $(this).height();
  
  // GET THE NEW HEIGHT DEFAULT TO 400 IF NOT SET
  var newheight = $(this).data('height') || 400;
  
  // SET THE NEW HEIGHT
    $(this).css({height: newheight + 'px'});
  
  // STORE THE OLD HEIGHT FOR WHEN DONE
  $(this).data('height', saved);
  });
  
  $('video').on('ended', function (e) {
    // SAVE THE CURRENT HEIGHT
    var fullheight = $(this).height();
  
    // GET THE OLD HEIGHT DEFAULT TO 100 IF NOT SET
    var newheight = $(this).data('height') || 100;
	
    // SET THE DEFAULT HEIGHT
    $(this).css({height: newheight + 'px'});
  
    // RESTORE THE FULL HEIGHT VALUE
    $(this).data('height', fullheight);
  });
});
</script>

Open in new window

Working sample here

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
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
Hi Julian,

Thank you for the good solution. There are some other related issues posted at: http://www.experts-exchange.com/questions/28736070/video-player-height-part-2.html

I wonder if you could take a look at this question?

Thank you,

Mike
Julian HansenCommented:
You are welcome, Mike.
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.