Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop video when closing the modal #89

Closed
Wakkos opened this issue Jan 29, 2014 · 9 comments
Closed

Stop video when closing the modal #89

Wakkos opened this issue Jan 29, 2014 · 9 comments
Labels
Milestone

Comments

@Wakkos
Copy link

Wakkos commented Jan 29, 2014

Hi,

When I add a HTML5 video and close the modal, the video keeps playing on background.

<section class="semantic-content" id="modal-text" tabindex="-1"
        role="dialog" aria-labelledby="modal-label" aria-hidden="true">

    <div class="modal-inner">
        <header id="modal-label"><!-- Header --></header>
        <div class="modal-content">
          <video preload="auto" controls poster="video/video.jpg">
            <source src="video/video.webm" type="video/webm">
            <source src="video/video.ogg" type="video/ogg"/>
            <source src="video/video.mp4" type="video/mp4">
          </video>
        </div>
        <footer><!-- Footer --></footer>
    </div>

    <a href="#!" class="modal-close" title="Close this modal" data-close="Close"
        data-dismiss="modal">×</a>
 </section>

Should we add some JS to stop the video from playing? I don't find any way to do this with HTML/CSS.

@anselmh
Copy link
Contributor

anselmh commented Jan 29, 2014

Yes, this should be done in JavaScript IMO. It’s a simple thing and should be added in a future version to improve video/audio support.

@Wakkos
Copy link
Author

Wakkos commented Jan 29, 2014

I suck at JS, but I came with this quick solution:

function stopVideo() {
 document.getElementById('video').pause();
}

And then add the ID="video" to my video tag in HTML.

The problem is that we have t modify the close link with onclick="stopVideo()". I can bet that there's a better way to do it if we detect the bookmark URL to play or pause the video.

@anselmh
Copy link
Contributor

anselmh commented Jan 29, 2014

I think there’s a better way to do this. Will dig into when finding some time, thanks for your report and quick solution.

@drublic
Copy link
Owner

drublic commented Jan 29, 2014

We should utilize the custom events of CSS Modal. This is nothing that we
should add to the core, IMO, since not everybody uses video. There could be
a plugin snipped which adds the functionality.

On Wed, Jan 29, 2014 at 1:15 PM, Anselm Hannemann
notifications@github.comwrote:

I think there's a better way to do this. Will dig into when finding some
time, thanks for your report and quick solution.

Reply to this email directly or view it on GitHubhttps://github.com//issues/89#issuecomment-33579352
.

@grayghostvisuals
Copy link
Contributor

I'm doing this right now with Froogaloop that hooks into the Vimeo API. https://github.com/vimeo/player-api/tree/master/javascript

// Robodemo
var roboDemo = $('#ipad_video');

// Play Robodemo
function playRoboDemo(playerID) {
    var player = $f(playerID.get(0));

    // Player Ready Event
    player.addEvent('ready', function() {
        player.api('play');
    });
}

// Pause Robodemo
function pauseRoboDemo(playerID) {
    var player = $f(playerID.get(0));

    // Player Ready Event
    player.addEvent('ready', function() {
        player.api('pause');
    });
}

// Add these to your click events or scroll if you want
playRoboDemo(roboDemo);
puaseRoboDemo(roboDemo);

@Wakkos
Copy link
Author

Wakkos commented Jan 30, 2014

@drublic is kind of right, it it's a CSS modal then it would stop being CSS. but as you said, this JS would be for "flavoring" its use. Allowing html5 video in modal. (and maybe a fullscreen mode?).

But it ups to you guys!

@drublic
Copy link
Owner

drublic commented Jan 30, 2014

Can we create a directory plugins and add JS functionality for videos
aso. there? I'd like to see that.

On Thu, Jan 30, 2014 at 1:15 PM, Daniel Martínez
notifications@github.comwrote:

@drublic https://github.com/drublic is kind of right, it it's a _CSS_modal then it would stop being
CSS. but as you said, this JS would be for "flavoring" its use.
Allowing html5 video in modal. (and maybe a fullscreen mode?).

But it ups to you guys!

Reply to this email directly or view it on GitHubhttps://github.com//issues/89#issuecomment-33682463
.

@anselmh
Copy link
Contributor

anselmh commented Jan 30, 2014

Yes, think this would be a good idea. We also could provide one plugin for html5 video and another for the vimeo API then…

@Wakkos
Copy link
Author

Wakkos commented Jan 30, 2014

That sounds Awesome.

drublic added a commit that referenced this issue Feb 1, 2014
anselmh added a commit that referenced this issue Feb 10, 2014
@anselmh anselmh mentioned this issue Feb 10, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants