为什么这种声音只在Chrome上显示

问题描述 投票:0回答:1

当Paypal捕获订单并获得批准时,我正在显示声音。问题在于,声音只会在Google Chrome上显示,而只能在计算机上显示。不能在Safari中使用,也不能在chrome设备中使用。但更奇怪的是,它曾经在Mac的safari上工作,然后,当我再次尝试时,它停止工作,现在仅在chrome上工作。

这是我的代码,在此先感谢:

<script>
paypal.Buttons({
    createOrder: function(data, actions) {
      // This function sets up the details of the transaction, including the amount and line item details.
      return actions.order.create({
        application_context: {
                shipping_preference: 'NO_SHIPPING',
            },
        purchase_units: [{
          amount: {
            value: '1.99'
          }
        }]
      });
    },
onApprove: function(data, actions) {
      var bleep = new Audio();
      bleep.setAttribute("src", "static/payment_success.m4a");
      bleep.currentTime=0;
      bleep.play();

some more code.....
}).render('#paypal-button-container');
</script>
javascript audio paypal safari
1个回答
0
投票

您可能会检查Audio.canPlayType是否支持某些音频格式并进行播放。

© www.soinside.com 2019 - 2024. All rights reserved.