Showing results for 
Search instead for 
Do you mean 
If you don't find an answer, please click here to post your question.

Autoplay for Safari 11: Script Example

Started ‎09-21-2017 by
Modified ‎09-21-2017 by

Autoplay for Safari 11: Script Example

by Ooyalan on ‎09-21-2017 12:44 PM (1,741 Views)

Below is a sample script of a pop-up message you can display on your webpage asking customers to add your site to the allowed list for unmuted autoplay.



 // Detect browser for mac OS safari 11+, then alert a "message" to end user.

 (function() {

   try {

     // Detect if the browser is safari AND if it is running on Mac OS

     var isMacSafari = window.safari !== undefined && !!window.navigator.platform.match(/Mac/);

     if (isMacSafari) {

       // Parse the browser version for use

       var version = parseInt(window.navigator.userAgent.match(/Version\/(\d+)/)[1], 10);

       // If safari version 11+, alert or log a message

       if (version >= 11) {

         // Site owner to decide if alert is the right recommendation

         alert("For optimal playback experience on your Safari browser, enable autoplay for this website by navigating to Safari-> Settings for this web site -> Auto-play: Allow All Autoplay");



   } catch (e) {}