()
| 897 | } else { |
| 898 | // Fire this when the sound is ready to play to begin HTML5 Audio playback. |
| 899 | var playHtml5 = function() { |
| 900 | node.currentTime = seek; |
| 901 | node.muted = sound._muted || self._muted || Howler._muted || node.muted; |
| 902 | node.volume = sound._volume * Howler.volume(); |
| 903 | node.playbackRate = sound._rate; |
| 904 | |
| 905 | // Some browsers will throw an error if this is called without user interaction. |
| 906 | try { |
| 907 | var play = node.play(); |
| 908 | |
| 909 | // Support older browsers that don't support promises, and thus don't have this issue. |
| 910 | if (play && typeof Promise !== 'undefined' && (play instanceof Promise || typeof play.then === 'function')) { |
| 911 | // Implements a lock to prevent DOMException: The play() request was interrupted by a call to pause(). |
| 912 | self._playLock = true; |
| 913 | |
| 914 | // Set param values immediately. |
| 915 | setParams(); |
| 916 | |
| 917 | // Releases the lock and executes queued actions. |
| 918 | play |
| 919 | .then(function() { |
| 920 | self._playLock = false; |
| 921 | node._unlocked = true; |
| 922 | if (!internal) { |
| 923 | self._emit('play', sound._id); |
| 924 | } else { |
| 925 | self._loadQueue(); |
| 926 | } |
| 927 | }) |
| 928 | .catch(function() { |
| 929 | self._playLock = false; |
| 930 | self._emit('playerror', sound._id, 'Playback was unable to start. This is most commonly an issue ' + |
| 931 | 'on mobile devices and Chrome where playback was not within a user interaction.'); |
| 932 | |
| 933 | // Reset the ended and paused values. |
| 934 | sound._ended = true; |
| 935 | sound._paused = true; |
| 936 | }); |
| 937 | } else if (!internal) { |
| 938 | self._playLock = false; |
| 939 | setParams(); |
| 940 | self._emit('play', sound._id); |
| 941 | } |
| 942 | |
| 943 | // Setting rate before playing won't work in IE, so we set it again here. |
| 944 | node.playbackRate = sound._rate; |
| 945 | |
| 946 | // If the node is still paused, then we can assume there was a playback issue. |
| 947 | if (node.paused) { |
| 948 | self._emit('playerror', sound._id, 'Playback was unable to start. This is most commonly an issue ' + |
| 949 | 'on mobile devices and Chrome where playback was not within a user interaction.'); |
| 950 | return; |
| 951 | } |
| 952 | |
| 953 | // Setup the end timer on sprites or listen for the ended event. |
| 954 | if (sprite !== '__default' || sound._loop) { |
| 955 | self._endTimers[sound._id] = setTimeout(self._ended.bind(self, sound), timeout); |
| 956 | } else { |
no test coverage detected