Skip to content

Commit

Permalink
SMD-2149 Release iOS SDK
Browse files Browse the repository at this point in the history
- Improved bitrate selector
  • Loading branch information
Stefano Russello committed May 18, 2023
1 parent f499108 commit 0215565
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Change Log:

All notable changes to this project will be documented in this section.

### 1.2.2
- Improved bitrate selector

### 1.2.1
- Default subtitle track auto-selected
- Get Label caption on subtitle selector
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ class AMGPlayKitStandardControl: UIView, AMGControlDelegate {
button.addTarget(self, action: #selector(swapBitRate(button:)), for: .touchUpInside)
self.bitrateScroll.addSubview(button)
withBitrateList.forEach { bitrate in
let button = createButtonLabel(text: "\(bitrate.bitrate ?? 0)", width: maxWidth, index: count, selectedIndex: self.selectedBitrate, colors: selectorColors)
let button = createButtonLabel(text: "\(bitrate.height ?? 0)p", width: maxWidth, index: count, selectedIndex: self.selectedBitrate, colors: selectorColors)
button.addTarget(self, action: #selector(swapBitRate(button:)), for: .touchUpInside)
self.bitrateScroll.addSubview(button)
count += 1
Expand Down Expand Up @@ -770,6 +770,7 @@ class AMGPlayKitStandardControl: UIView, AMGControlDelegate {
tText.setTitle(text, for: .normal)
tText.setTitleColor(.white, for: .normal)
tText.contentHorizontalAlignment = .left
tText.titleLabel?.lineBreakMode = .byWordWrapping
tText.titleEdgeInsets = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 0)

if index == selectedIndex {
Expand Down
18 changes: 17 additions & 1 deletion Source/StreamSDKPlayKit/Player/Media/MediaContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,23 @@ public struct MediaContext: Codable {
public let flavorAssets: [FlavorAsset]

public func fetchBitrates() -> [FlavorAsset] {
return flavorAssets.sorted(by: {$0.width ?? 0 < $1.width ?? 0})
var uniqueAssets: [Int: FlavorAsset] = [:] // Dictionary to store unique assets by height

for flavorAsset in flavorAssets {
if let height = flavorAsset.height {
if let existingAsset = uniqueAssets[Int(height)] {
if let existingBitrate = existingAsset.bitrate, let currentBitrate = flavorAsset.bitrate {
if existingBitrate < currentBitrate {
uniqueAssets[Int(height)] = flavorAsset // Replace with higher bitrate asset
}
}
} else {
uniqueAssets[Int(height)] = flavorAsset // Add new unique asset
}
}
}

return Array(uniqueAssets.values).sorted { $0.bitrate ?? 0 < $1.bitrate ?? 0 } // Convert dictionary values to an array and return it sorted
}
}

Expand Down
2 changes: 1 addition & 1 deletion StreamAMGSDK.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Pod::Spec.new do |spec|

spec.name = "StreamAMGSDK"
spec.version = "1.2.1"
spec.version = "1.2.2"
spec.summary = "Stream AMG SDK"
spec.swift_versions = "5"

Expand Down

0 comments on commit 0215565

Please sign in to comment.