Disable iOS Safari lock screen scrubber for media

后端 未结 3 462
时光取名叫无心
时光取名叫无心 2021-01-18 10:31

Safari on iOS puts a scrubber on its lock screen for simple HTMLAudioElements. For example:

const a = new Audio();
a.src = \'https://example.com/audio.m4a\'         


        
相关标签:
3条回答
  • 2021-01-18 10:51

    I did a search, in search of a way to help you, but I did not find an effective way to disable the commands, however, I found a way to customize them, it may help you, follow the apple tutorial link

    I think what's left to do now is wait, see if ios 13 will bring some option that will do what you want.

    0 讨论(0)
  • 2021-01-18 11:01

    DISABLE Player on lock screen completely

    if you want to completely remove the lock screen player you could do something like

    const a = new Audio();
    document.querySelector('button').addEventListener('click', (e) => {
      a.src = 'http://sprott.physics.wisc.edu/wop/sounds/Bicycle%20Race-Full.m4a' 
      a.play();
    });
    
    document.addEventListener('visibilitychange', () => {
      if (document.hidden) a.src = undefined
    })
    
    

    https://jsfiddle.net/5s8c9eL0/3/

    that is stoping the player when changing tab or locking screen (code to be cleaned improved depending on your needs)

    0 讨论(0)
  • 2021-01-18 11:10

    From my understanding you can't block/hide the scrubbing commands unless you can tag the audio as a live stream. That being said, you can use js to refuse scrubbing server-side. Reference the answer here. Although that answer speaks of video, it also works with audio.

    0 讨论(0)
提交回复
热议问题