0
votes

I'm developing iOS app which uses HLS. In our video platform we use Nginx proxy_pass module for redirecting from one origin to another when one of them becomes unavailable (at all we have 2 origins). Switching between origins is transparent for client, it's maintained by balancer, for client playlist URI stays unchanged.

We faced a problem with AVPlayer with such switching workflow wich also appear in QuickTime. According to network log next things happens:

At the moment of switching AVPlayer asks for live playlist again and when it finishes playing chunks loaded before switching it starts to play not the next chunk in playlist but the first! And there no change in AVPlayer currentTime property, it continues to change like there was no switching on the first chunk (in normal seeking at the start of playlist currentTime will be 0), no player item status changes happen, no notifications are thrown, nothing special in access log, error log is empty at all. So we can't update user interface (i.e. seek bar) and alter user that he was redirected to another time of live streeam. And the problem is even worse in context that we should not show user the live stream out of bounds of particular broadcast.

Any suggestions how to solve this? Or it's core AVPlayer bug (as far as this issue also appear in Quicktime)?

1

1 Answers

0
votes

The solution was: 1) to use different names for playlist on different origins, 2) send back to client 404 or another error when trying to update playlist from disabled origin, 3) use fallback in playlists - add second, alternative playlist from second origin in multibitrait playlist. It's stated in HLS documentation. When AVPlayer recieve error while updating playlist it tryes to update from fallback playlist 4) to provide manual quality selection, we had also to wrap playilists for particular qualities in intermediate variant playlists with master playlist and fallback playlist. FMS which we use for generating playlists from livestream can't do that, so we needed to generate variant playlist on side of Nginx

The result is fault-tolerant video platform with transparent switching between master and slave (second) origins which works with auto and manual quality selection.