From 56f9d3a4983a3fbf2ebbbc19785e942110a6d618 Mon Sep 17 00:00:00 2001 From: Stefano Russello Date: Mon, 5 Jun 2023 13:09:23 +0200 Subject: [PATCH] SMD-2228 Release iOS SDK - Bitrate and subtitle icon hidden if not exist - Fixed position of subtitle icon if bitrate not exist - Added custom minimise icon - Update documentation --- Changelog.md | 4 ++++ PlayKitReadme.md | 5 ++++ .../Controls/AMGPlayKitStandardControl.swift | 23 ++++++++++++++++--- ...itStandardControlsConfigurationModel.swift | 10 +++++++- .../Player/PlayKit/AMGPlayKit.swift | 2 ++ StreamAMGSDK.podspec | 2 +- 6 files changed, 41 insertions(+), 5 deletions(-) diff --git a/Changelog.md b/Changelog.md index d8521e1..7793e3a 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,6 +3,10 @@ Change Log: All notable changes to this project will be documented in this section. +### 1.2.3 +- Improved bitrate/subtitle icon logic +- Added custom minimise icon + ### 1.2.2 - Improved bitrate selector diff --git a/PlayKitReadme.md b/PlayKitReadme.md index 1a901cb..3a6f3ca 100644 --- a/PlayKitReadme.md +++ b/PlayKitReadme.md @@ -211,6 +211,11 @@ Specify the image to use for the fullscreen button .fullScreenImage(_ image: String) ``` +Specify the image to use for the minimise button +``` Swift +.minimiseImage(_ image: String) +``` + Hide the 'fullscreen' button when the player is not in full screen ``` Swift .hideFullScreenButton() diff --git a/Source/StreamSDKPlayKit/Player/Controls/AMGPlayKitStandardControl.swift b/Source/StreamSDKPlayKit/Player/Controls/AMGPlayKitStandardControl.swift index 1f091ec..bcea883 100644 --- a/Source/StreamSDKPlayKit/Player/Controls/AMGPlayKitStandardControl.swift +++ b/Source/StreamSDKPlayKit/Player/Controls/AMGPlayKitStandardControl.swift @@ -379,6 +379,7 @@ class AMGPlayKitStandardControl: UIView, AMGControlDelegate { settingsButton.setImage(settingsImage, for: .normal) settingsButton.addTarget(self, action: #selector(openBitrateView), for: .touchUpInside) settingsButton.layer.cornerRadius = 8 + settingsButton.isHidden = true mainView.addSubview(settingsButton) } @@ -393,6 +394,7 @@ class AMGPlayKitStandardControl: UIView, AMGControlDelegate { subtitlesButton.setImage(subtitlesImage, for: .normal) subtitlesButton.addTarget(self, action: #selector(openSubtitlesView), for: .touchUpInside) subtitlesButton.layer.cornerRadius = 8 + subtitlesButton.isHidden = true mainView.addSubview(subtitlesButton) } @@ -402,7 +404,6 @@ class AMGPlayKitStandardControl: UIView, AMGControlDelegate { } - func updateIsLive(){ DispatchQueue.main.async { [self] in @@ -661,7 +662,7 @@ class AMGPlayKitStandardControl: UIView, AMGControlDelegate { // If bitrate selector is visible , then display subtitles button next to bitrate selector , // else move subtitles button to end of frame - if configModel.bitrateSelector { + if configModel.bitrateSelector && !settingsButton.isHidden { subtitlesButton.frame = CGRect(x: settingsButton.frame.origin.x - subtitlesButton.frame.width, y: h - skipSize - 5, width: skipSize, height: skipSize) } else { subtitlesButton.frame = CGRect(x: w - skipSize - 20, y: h - skipSize - 5, width: skipSize, height: skipSize) @@ -700,6 +701,15 @@ class AMGPlayKitStandardControl: UIView, AMGControlDelegate { var count = 0 DispatchQueue.main.async { [self] in self.subtitlesScroll.removeFromSuperview() + + if withTracks.isEmpty { + subtitlesButton.isHidden = true + return + } else { + subtitlesButton.isHidden = false + } + resize() + self.subtitlesScroll = self.createContentScroll(scrollViewWidth: maxWidth, itemCount: self.tracks.count) self.tracks.forEach { track in @@ -730,8 +740,15 @@ class AMGPlayKitStandardControl: UIView, AMGControlDelegate { var count = 1 DispatchQueue.main.async { [self] in self.bitrateScroll.removeFromSuperview() - self.bitrateScroll = createContentScroll(scrollViewWidth: maxWidth, itemCount: self.bitrates.count + 1) + if withBitrateList.isEmpty { + settingsButton.isHidden = true + return + } else { + settingsButton.isHidden = false + } + + self.bitrateScroll = createContentScroll(scrollViewWidth: maxWidth, itemCount: self.bitrates.count + 1) let button = createButtonLabel(text: "Auto", width: maxWidth, index: 0, selectedIndex: self.selectedBitrate, colors: selectorColors) button.addTarget(self, action: #selector(swapBitRate(button:)), for: .touchUpInside) diff --git a/Source/StreamSDKPlayKit/Player/Controls/AMGPlayKitStandardControlsConfigurationModel.swift b/Source/StreamSDKPlayKit/Player/Controls/AMGPlayKitStandardControlsConfigurationModel.swift index 6ed1777..f455c39 100644 --- a/Source/StreamSDKPlayKit/Player/Controls/AMGPlayKitStandardControlsConfigurationModel.swift +++ b/Source/StreamSDKPlayKit/Player/Controls/AMGPlayKitStandardControlsConfigurationModel.swift @@ -97,6 +97,14 @@ public class AMGControlBuilder { return self } + /** + Specify the image to use for the minimise button + */ + public func minimiseImage(_ image: String) -> AMGControlBuilder { + self.minimiseImage = image + return self + } + /** Specify the image to use for the skip forwards button */ @@ -294,7 +302,7 @@ public class AMGControlBuilder { Returns a complete and valid AMGPlayKitStandardControlsConfigurationModel */ public func build() -> AMGPlayKitStandardControlsConfigurationModel { - return AMGPlayKitStandardControlsConfigurationModel(fadeInTogglesPausePlay: fadeInTogglesPausePlay, fadeInTime: fadeInTime, fadeOutTime: fadeOutTime, fadeOutAfter: fadeOutAfter, trackTimeShowing: trackTimeShowing, isLiveImage: isLiveImage, logoImage: logoImage, playImage: playImage, pauseImage: pauseImage, skipForwardImage: skipForwardImage, skipBackwardImage: skipBackwardImage, fullScreenImage: fullScreenImage, hideFullscreen: hideFullscreen, hideMinimise: hideMinimise, liveTrack: liveTrack, vodTrack: vodTrack, bitrateSelector: bitrateSelector, subTitlesSelector: subTitlesSelector) + return AMGPlayKitStandardControlsConfigurationModel(fadeInTogglesPausePlay: fadeInTogglesPausePlay, fadeInTime: fadeInTime, fadeOutTime: fadeOutTime, fadeOutAfter: fadeOutAfter, trackTimeShowing: trackTimeShowing, isLiveImage: isLiveImage, logoImage: logoImage, playImage: playImage, pauseImage: pauseImage, skipForwardImage: skipForwardImage, skipBackwardImage: skipBackwardImage, fullScreenImage: fullScreenImage, minimiseImage: minimiseImage, hideFullscreen: hideFullscreen, hideMinimise: hideMinimise, liveTrack: liveTrack, vodTrack: vodTrack, bitrateSelector: bitrateSelector, subTitlesSelector: subTitlesSelector) diff --git a/Source/StreamSDKPlayKit/Player/PlayKit/AMGPlayKit.swift b/Source/StreamSDKPlayKit/Player/PlayKit/AMGPlayKit.swift index b9ac9d0..b23b72c 100644 --- a/Source/StreamSDKPlayKit/Player/PlayKit/AMGPlayKit.swift +++ b/Source/StreamSDKPlayKit/Player/PlayKit/AMGPlayKit.swift @@ -348,6 +348,8 @@ import AVKit if let textTracks = event.tracks?.textTracks { self?.checkDefaultCaptionTrack(textTracks: textTracks) self?.controlUI?.createSubtitlesSelector(withTracks: textTracks) + } else { + self?.controlUI?.createSubtitlesSelector(withTracks: []) } if let tracksExist = self?.tracks { self?.listener?.tracksAvailable(tracks: tracksExist) diff --git a/StreamAMGSDK.podspec b/StreamAMGSDK.podspec index 0bea79f..44af28a 100644 --- a/StreamAMGSDK.podspec +++ b/StreamAMGSDK.podspec @@ -2,7 +2,7 @@ Pod::Spec.new do |spec| spec.name = "StreamAMGSDK" - spec.version = "1.2.2" + spec.version = "1.2.3" spec.summary = "Stream AMG SDK" spec.swift_versions = "5"