Skip to content

Commit

Permalink
Merge pull request #8 from StreamAMG/release/1.1.5
Browse files Browse the repository at this point in the history
SMD-1462 Rotation issue
  • Loading branch information
StefanoStream authored Nov 3, 2022
2 parents 6c577d5 + 4f7af3b commit 4b09b29
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 25 deletions.
18 changes: 18 additions & 0 deletions PlayKitReadme.md
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,24 @@ func bitrateChangeOccurred(list: [FlavorAsset]?) {

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

### 1.1.5
- Fixed rotation issue on iOS 16

### 1.1.4
- Switched bitrate from Int64 to FlavorAsset class
- Added callback to updateBitrateSelector
- Exposed list of bitrate through AMGPlayKitListener. bitrateChangeOccurred
- Added setBitrateAuto function
- Deprecated setMaximumBitrate(bitrate: Double)
- Change the hide custom controls method visibility to Public
- Created a new interface to add custom views on top of Playerview

### 1.1.3
- Enhanced IAP raw receipt

### 1.1.2
- Updated IAP package API.

### 1.1.1
- Added startPosition to loadMedia
- Download to Go compatible with Objective-C
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ Change Log:

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

### 1.1.5 - Fixed rotation issue on iOS 16

### 1.1.4 - Improved PlayKit

### 1.1.3 - Enhanced IAP raw receipt

### 1.1.2 - Updated IAP package API.

### 1.1.1 - PlayKit minor update
Expand Down
79 changes: 55 additions & 24 deletions Source/StreamSDKPlayKit/Player/PlayKit/AMGPlayKit+Orientation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import UIKit

extension AMGPlayKit {


override public var bounds: CGRect {
didSet {
resizeScreen()
Expand All @@ -24,43 +25,73 @@ extension AMGPlayKit {
}

func resizeScreen(){

playerView?.frame = self.bounds
controlUI?.frame = self.bounds
if #available(iOS 13.0, *) {
self.controlUI?.setFullScreen(UIDevice.current.orientation.isValidInterfaceOrientation ? UIDevice.current.orientation.isLandscape : (UIApplication.shared.windows.first?.windowScene?.interfaceOrientation.isLandscape ?? false))

var isInFullScreen = false
/// Checking current player rotation status
if UIApplication.shared.statusBarOrientation.isLandscape {
isInFullScreen = true
} else {
self.controlUI?.setFullScreen(UIDevice.current.orientation.isValidInterfaceOrientation ? UIDevice.current.orientation.isLandscape : UIApplication.shared.statusBarOrientation.isLandscape)
isInFullScreen = false
}

self.controlUI?.setFullScreen(isInFullScreen)

controlUI?.resize()
}

public func minimise() {
if orientationTime > Date().timeIntervalSince1970 - 1.0 {
return
DispatchQueue.main.async { [self] in
if orientationTime > Date().timeIntervalSince1970 - 1.0 {
return
}
orientationTime = Date().timeIntervalSince1970

if #available(iOS 16.0, *) {
let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene
windowScene?.requestGeometryUpdate(.iOS(interfaceOrientations: .portrait))
UIApplication.shared.inputViewController?.setNeedsUpdateOfSupportedInterfaceOrientations()
UIApplication.shared.inputViewController?.navigationController?.setNeedsUpdateOfSupportedInterfaceOrientations()
} else {
let value = UIInterfaceOrientation.portrait.rawValue
UIDevice.current.setValue(value, forKey: "orientation")
UIViewController.attemptRotationToDeviceOrientation()
}

resizeScreen()
playerView?.layoutIfNeeded()
}
orientationTime = Date().timeIntervalSince1970
let value = UIInterfaceOrientation.portrait.rawValue
UIDevice.current.setValue(value, forKey: "orientation")
UIViewController.attemptRotationToDeviceOrientation()
controlUI?.setFullScreen(false)
resizeScreen()
playerView?.layoutIfNeeded()
}

public func fullScreen() {
if orientationTime > Date().timeIntervalSince1970 - 1.0 {
return
}
orientationTime = Date().timeIntervalSince1970
var value = UIInterfaceOrientation.landscapeRight.rawValue
if UIApplication.shared.statusBarOrientation == .landscapeLeft {
value = UIInterfaceOrientation.landscapeLeft.rawValue
DispatchQueue.main.async {
if self.orientationTime > Date().timeIntervalSince1970 - 1.0 {
return
}

self.orientationTime = Date().timeIntervalSince1970

if #available(iOS 16.0, *) {
let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene
let orientation = windowScene?.interfaceOrientation
windowScene?.requestGeometryUpdate(.iOS(interfaceOrientations: orientation == .portrait ? .landscape : .portrait))
UIApplication.shared.inputViewController?.setNeedsUpdateOfSupportedInterfaceOrientations()
UIApplication.shared.inputViewController?.navigationController?.setNeedsUpdateOfSupportedInterfaceOrientations()
} else {
var value = UIInterfaceOrientation.landscapeRight.rawValue
if UIApplication.shared.statusBarOrientation == .landscapeLeft {
value = UIInterfaceOrientation.landscapeLeft.rawValue
}

UIDevice.current.setValue(value, forKey: "orientation")
UIViewController.attemptRotationToDeviceOrientation()
}

self.resizeScreen()
self.playerView?.layoutIfNeeded()
}
UIDevice.current.setValue(value, forKey: "orientation")
UIViewController.attemptRotationToDeviceOrientation()
controlUI?.setFullScreen(true)
resizeScreen()
playerView?.layoutIfNeeded()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public protocol AMGPlayerDelegate: AnyObject {

func minimise()
func fullScreen()
func setBitrateAuto()
func setMaximumBitrate(bitrate: FlavorAsset?)
}

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.1.4"
spec.version = "1.1.5"
spec.summary = "Stream AMG SDK"
spec.swift_versions = "5"

Expand Down

0 comments on commit 4b09b29

Please sign in to comment.