Ninja Slider / Posts /

Close video once finished

0

Curious how do I auto close video and return to original screen once video has finished? My js code is minimized so not able to explore the code. Thanks!

Brandon  7 years ago   viewed: 3314    

13 Answers

0

What video are you playing? Vimeo, Youtube or HTML video?

Milo   7 years ago
0

YouTube 

(said content is too short so adding meaningless words here)

Brandon   7 years ago
-1

Then you can open ninjaVieoPlugin.mini.js, search for:

,500);_zSlider.next()

and replace it with:

,500);
Milo   7 years ago
0

Didn't seem to change anything. Once the video ends it closes the video player to original screen for a second (how I want it too), but then the youtube player opens back up to the end of the video.

Brandon   7 years ago
0

Then please try another work around. Open ninjaVieoPlugin.mini.js, search for:

,500);_zSlider.next()

and replace it with:

,500);_zSlider.next();nslider.prev()
Milo   7 years ago
0

Really close. It is closing the video after it has finished which I want, but it is sliding to the next videos placeholder screen instead of returning to original screen of the video the user is watching. 

I can deal with it as is, but if it isn't to much more work I would like to adjust. THANKS!

Brandon   7 years ago
0

The nslider.prev() will make the slider immediately come back to the current slide.

So if you haven't changed the slider name, nslider, that is the following line in ninja-slider.js:

var nslider = new NinjaSlider(nsOptions);

Then nslider.prev() should bring the next slide back to the current slide.

Milo   7 years ago
0

I haven't changed the name and for whatever reason it isn't working. When it closes it is sliding to the next videos placeholder image instead of just closing to the current videos placeholder that was clicked.

Is there something like this we can put in?

function onPlayerStateChange(event) {        
            if(event.data === 0) {          
                // close video
            }
        }
Brandon   7 years ago
0

Sorry my previous workaround doesn't work.

Please try another approach. Search for:

else if(a.data==0){setTimeout(function(){_zSlider.iframe.src=_zSlider.iframe.getAttribute("src");_zSlider.iframe.parentNode.parentNode.yplayer=new YT.Player(_zSlider.iframe.id,{events:{onStateChange:onYTPlayerStateChange}})},500);_zSlider.next()}}

And replace it with:

else if(a.data==0){_zSlider.next(); setTimeout(function () { nslider.prev(); nslider.toggle();}, 20);}}

I have added nslider.toggle(); in above line to stop the slider. If you don't want to stop it, remove that command. If you want to stop it for some time but not forever, you can add another setTimeout to call the nslider.toggle() again to start the slider.

Milo   7 years ago
0

It some what works now. So I have 3 slides with embedded youtube videos with a placeholder image over the top of each video slide that you have to click to play the video. When I click the first or last slide and open the youtube video and it plays and finishes it closes back to original/correct placeholder. But when I click on the second/middle slider and its youtube video finishes, it closes and slides me over to the last/third placeholder slide image instead of the placeholder image that was clicked (second/middle).

Any idea why that would be? Thanks!

Brandon   7 years ago
0
And it looks like my first slides video when finished is closing and sliding to the last/third slide as well... just not everytime? 

So maybe it is something with the "zSlider.next"? The only reason the third/last slide closes correctly because it can't slide right/next.
Brandon   7 years ago
0

How about if you increase the delay from 20 to 120 in my workaround:

else if(a.data==0){_zSlider.next(); setTimeout(function () { nslider.prev(); nslider.toggle();}, 120);}}
Milo   7 years ago
0

Kind of works. Sometimes it works, sometimes it doesn't. It just seems really glitchy. I will make do with it. Thanks for your help!

Brandon   7 years ago

   

Your name*
Password
(Optional. Used to modify this post afterwords)
+ =  

Ask your Own Question

  • If your question is related to the topic of this post, you can post your question to this page by clicking the "Post a reply" button at left;

  • When you want to start a new page for your question: