BrikerMan / BMPlayer

A video player for iOS, based on AVPlayer, support the horizontal, vertical screen. support adjust volume, brightness and seek by slide, support subtitles.
https://eliyar.biz
MIT License
1.96k stars 418 forks source link

How to extract languages form m3u8 URL? #305

Open kushalmaniyar opened 4 years ago

kushalmaniyar commented 4 years ago

Check List

Thanks for considering to open an issue. Before you submit your issue, please confirm these boxes are checked.

BMPlayer version

Installed with

Issue Description

What

How to extract language from m3u8 URL.

Reproduce

https://5a8ea362056bf.streamlock.net:1936/vodtoken/smil:E_vod.smil/playlist.m3u8

The above URL contains two languages, How can I extract language options and change the language? Skype_Picture_2020_05_23T10_12_50_030Z

when I open this URL in safari it allows me to choose a language. Can you please give me the process of how to extract the m3u8 file?

Thanks in advance. Kushal

kushalmaniyar commented 4 years ago

Hello,

Do you provide audio parsing ?

Pratik-Sodha commented 4 years ago

Application-level solution

func languageSelection() {

        guard let selectionGroup = player.playerLayer?.player?.currentItem?.asset.mediaSelectionGroup(forMediaCharacteristic: .audible) else {

            return
        }

        /**
         Supported auido list availble in array
         */
        let laguages : [AVMediaSelectionOption] = selectionGroup.options

        /*
         Select respective language from array index.
         */
        player.playerLayer?.player?.currentItem?.select(laguages.first, in: selectionGroup)

    }

Library Level

    open lazy var selectionGroup : AVMediaSelectionGroup? = {
        return player?.currentItem?.asset.mediaSelectionGroup(forMediaCharacteristic: .audible)
    }()

    open lazy var languages : [AVMediaSelectionOption] = {

        return selectionGroup?.options ?? []

    }()