Today, one of my work required the app to remember the track selection, so that it can be resumed when the app is resumed. The easy problem are how to store the values. The tricky problem is how to set AVPlayer’s item tracks.

From the AVPlayer documentation it seems quite tedious to get the tracks options. So here is a helper class to save the day. (In swift3)


With the help of simple Swift’s enum, and extension, we can do something like this:


Here are simple usage,

Hope this save someone headache!