a1k0n/jsxm

Autoplay

Opened this issue · 3 comments

Hi, I have a problem with autoplaying in my site...

  • Everytime I XMPlayer.init(); and fetch, I have to wait about 2 to 3 minutes before playing...
  • Here's how I did it...
     <script>
     // Play the XM file
      function play() {
        XMPlayer.play();
      }
	
      // Initialize the player
      XMPlayer.init();

      // Load the XM file
      fetch('a sad touch.xm')
        .then(response => response.arrayBuffer())
        .then(buffer => {
			XMPlayer.load(buffer);
			setTimeout(function(){
				play();
			}, 3500);
		});

      // Pause the XM file
      function pause() {
        XMPlayer.pause();
      }

      // Stop the XM file
      function stop() {
        XMPlayer.stop();
      }
    </script>
  • Is jsxm support autoplay after loaded xm? or I just live in pain?

Site: bang1338.xyz

a1k0n commented

Browsers don't allow you to autoplay audio on load without at least some interaction with the page. So for example I had to add a "play" button to start a demo with audio.

a1k0n commented

Does the 3-second delay actually work for autoplaying? Hmm

Does the 3-second delay actually work for autoplaying? Hmm

  • Yes, 3.5 seconds delay.
  • Put 3.5 seconds, work for Cent Browser, Chrome, Vivaldi Browser on Android.

Goal: Don't need 3.5 seconds waiting