Video overlay fine tuning...

I had a very good solution from Julian Hansen at: http://www.experts-exchange.com/questions/28736940/a-tag-with-OnClick.html

This works great; but there are some minor issues I need help with.

1. There is no maximize, stop or start buttons when the video is played. Is it possible with overlay to have play/stop or max buttons? If not I could just at least add a note like (ESC to cancel) to video description. In absence of maximize, I need to modify css to use maximum screen area.
2. As shown below, the video is not centered. I guess there need to be some adjustment to CSS to show the video centered.
overlay3. See http://datapassion.net/index.html , Video hyperlinks are spread through out index.html. The hyperlink at top works fine (user clicks on the hyperlink Data Upload under Kaiser Permanente and sees the video in the correct spot. But there is another hyperlink at the very bottom (under Other Companies... the second hyperlink). To get to this hyperlink at the bottom of index.html, users need to scroll down to it first but when they click on the hyperlink to see the video, the video starts playing on the top of the page not in view. So, user has to scroll up to see the video. How can I fix my css below to fix this issue.
.overlay {
  width: 100%;
  background: rgba(0,0,0,.75);
  position: absolute;
  left: 0;
  top: 0;
}
.videobox {
  width: 50%;
  position: absolute;
  left: 50%;
  margin-left: -25%;
  top: 10%;
  background: white;
  text-align: center;
  padding: 20px;
  border-radius: 5px;
  
}
.close {
  width: 36px;
  height: 36px;
  position: absolute;
  top: -18px;
  right: -18px;
  display: block;
  background: transparent url(images/close.png) no-repeat center center;
  opacity: .8;
}
.close:hover {
  opacity: 1;
}

Open in new window

LVL 34
Mike EghtebasDatabase and Application DeveloperAsked:
Who is Participating?
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:
1. Change by adding this to the existing code
Changes from
.append($('<video/>').prop('autoplay', true).attr('src', el.attr('href')))

Open in new window

To
.append($('<video/>').prop({autoplay: true, controls: true}).attr('src', el.attr('href')))

Open in new window


2. Centered video - remove the width from the .video-box style as well as the top, left and margin
.videobox {
  position: absolute;
  background: white;
  text-align: center;
  padding: 20px;
  border-radius: 5px;
}
.videobox video {
	width: 600px;
}

Open in new window

3. To solve the scroll offset we need to position the div - this means giving the video a width - if you don't do the width of the popup is not calculated correctly

jQuery source
<script>
$(function() {
  $(document).on('keyup',function(e) {
    if (e.keyCode == 27) {
      $('.overlay').remove();
    }
  });
  $('body').on('click','.overlay, .close', function() {
    $('.overlay').remove();
  });
  $('body').on('click','.videobox', function(e) {
    e.stopPropagation();
  });
  $('.video-link').click(function(e) {
    var el = $(this);
    e.preventDefault();
  var vbox =  $('<div/>').addClass('videobox').attr('id','conter');
    vbox.append($('<a/>').addClass('close'));
    vbox.append($('<video/>').prop({autoplay: true, controls: true}).attr('src', el.attr('href')));
    vbox.append($('<div/>').html(el.data('description')));

    $('body')
      .append(
        $('<div class="overlay"/>').height(Math.max($(document).height(), $(window).height()))
      .append(
        vbox
      )
    );
  var left  = ($(window).width() - vbox.width()) >> 1;
  var top = $(window).scrollTop() + 50;

  vbox.css({
    left: left + 'px',
    top: top + 'px'
  });
  });
});
</script>

Open in new window


Updated sample here
1

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:
Julian rules!
0
Julian HansenCommented:
:) thank you Mike, you are most 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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.