mediaelement.js - pause all players (iOS)

2019-08-06 17:02发布

问题:

I have an array (allPlayers) of MediaElement audio players. There are multiple players on the page, and I call this function when a new track is started, to ensure that no two tracks play simultaneously.

for (i = 0; i < allPlayers.length; i++) {
    allPlayers[i].pause();
}

It works fine, except not on iOS. Why does pause() not work in Safari Mobile?

回答1:

Let's try this code instead:

$('video,audio').mediaelementplayer().pause();