dailymotion / dailymotion-swift-player-sdk-ios

Dailymotion Player SDK for iOS in Swift
MIT License
33 stars 15 forks source link

qualitiesavailable event does not properly work #67

Open Alexis-Vautier opened 2 years ago

Alexis-Vautier commented 2 years ago

Hello I have an issue with the "qualitiesavailable" event. Every time I am using it, the only quality returned is 144P. I think it may be the preroll's quality. But, when the media starts, the "qualitiesavailable" is not called.

Is there a proper way to get the available qualities for a video and change the quality, without using the Dailymotion controls ? (I think the only way to do this is to reload the video, using the "start" and "quality" playerParameters)

Thanks; Best regards, Alexis

Alexis-Vautier commented 2 years ago

So, I searched in Dailymotion SDK and it is not Preroll's quality. In fact, there is an issue with the IOS SDK.

There was the same issue with Android :

https://github.com/dailymotion/dailymotion-player-sdk-android/pull/56

If you check in the : private static func parseEventAndParameters(from: String) method in theEventParser.swift file.

If juste add a condition :

private static func parseEventAndParameters(from: String) -> [String: String] {
    let splitedEvents = from.components(separatedBy: "&").map({ $0.components(separatedBy: "=") })
    var eventAndParameters: [String: String] = [:]
    for entry in splitedEvents {
      if let key = entry.first, let value = entry.last, !key.isEmpty, !value.isEmpty {
        **if let oldValue = eventAndParameters[key] {
            eventAndParameters[key] = oldValue.appending("|\(value)")
        } else {
            eventAndParameters[key] = value
        }**
      }
    }
    return eventAndParameters
  }

I just append all value, using a pipe to split them, instead of just remove the previous one. And...

Name qualitiesavailable -- Info Optional(["qualities[]": "1080|720|480|380|240|144"])

If you prefer a comma or an other typo, it does not matter. But can you please submit this fix ASAP please ? Thanks.

Best regards, Alexis

@RemiGuyon