Click here to Skip to main content
15,885,936 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to set a poster in html5 video tag automatically while page is loading. Thus why, I am using a jquery here:
JavaScript
<script>
            $(document).ready(function(){
                var vid = $('#v0')[0];

                vid.onplay = vid.onclick = function() {
                    vid.onplay = vid.onclick = null;

                    setTimeout(function() {
                        vid.pause();
                        setInterval(function() {
                            if ($.browser.opera) {
                                var oldHandler = vid.onplay;
                                vid.onplay = function() {
                                    vid.pause();
                                    vid.onplay = oldHandler;
                                };
                                vid.play();
                            } else {
                                vid.currentTime += (1 / 29.97);
                            }
                        }, 2000);
                    }, 12000);

                    setInterval(function() {
                        $('#time').html((vid.currentTime * 29.97).toPrecision(5));
                    }, 100);
                };
            });
            
        </script>

And in my HTML is here:
HTML
<body>
        <p id="time"></p>
        <video id="v0" controls tabindex="0" autobuffer preload>
        <p>Sorry, your browser does not support the <video> element.</p>
        </video>
</body>

But, when I am running my project, there skin is black in video tag and there is no first frame of the video in the skin. I think, my jquery is not working here. Have you any suggesstion to solve this problem?
Thank you.
Posted
Updated 27-Apr-13 20:34pm
v2
Comments
ExpertITM 28-Apr-13 4:45am    
have you tried with video source?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900