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

Needs better detection for autoPlay support. #30

Open
jfrux opened this issue May 21, 2014 · 2 comments
Open

Needs better detection for autoPlay support. #30

jfrux opened this issue May 21, 2014 · 2 comments

Comments

@jfrux
Copy link

jfrux commented May 21, 2014

May I suggest this logic and the addition of a $.fn.supportsAutoPlay function?

This is an example of detecting autoPlay, not sure how foolproof it is?
fairly psuedo-code not tested... sorry~

               $.fn.videoBG.supportsAutoPlay = function() {
                   var AUTOPLAY = false;
                try 
                {
                    var video = new Video();
                    video.autoplay = true;
                    video.volume = 0;

                    // this will only be triggered if autoplay works
                    $(video).on('play', function() {
                        AUTOPLAY = true;
                    });
                } 
                catch(e) 
                {
                    return false
                }

                return AUTOPLAY
            });
}
@jfrux
Copy link
Author

jfrux commented May 21, 2014

In fact, here is a jsfiddle link that if you load it in certain browsers and in mobile it will detect it...
http://jsfiddle.net/QqeX5/1/
http://fiddle.jshell.net/QqeX5/1/show

@jfrux
Copy link
Author

jfrux commented May 21, 2014

Meh... I see where there could be issues...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant