Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit cdb6ea4

Browse files
Expose fill and fit parameters for iOS (#344)
1 parent 79c4d73 commit cdb6ea4

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

ios/Classes/VideoView/FLVideoView.swift

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ class FLVideoView: NSObject, FlutterPlatformView {
4040
do {
4141
let participantId: String? = try flutterArguments.asDictionary(argKey: "participant_id").decode()
4242
let mediaStreamId: String? = try flutterArguments.asDictionary(argKey: "media_stream_id").decode()
43-
try attach(participantId: participantId, mediaStreamId: mediaStreamId)
43+
let scaleType: String? = try flutterArguments.asDictionary(argKey: "scale_type").decode()
44+
try attach(participantId: participantId, mediaStreamId: mediaStreamId, scaleType: scaleType)
4445
} catch {
4546
completionHandler.failure(error)
4647
}
@@ -65,7 +66,7 @@ class FLVideoView: NSObject, FlutterPlatformView {
6566
completionHandler.success(flutterConvertible: false) // TODO: Implement this properly
6667
}
6768

68-
private func attach(participantId: String?, mediaStreamId: String?) throws {
69+
private func attach(participantId: String?, mediaStreamId: String?, scaleType: String?) throws {
6970
guard
7071
let participantId = participantId, participantId != "",
7172
let mediaStreamId = mediaStreamId, mediaStreamId != "",
@@ -78,8 +79,20 @@ class FLVideoView: NSObject, FlutterPlatformView {
7879
_view.unattach()
7980
return
8081
}
82+
updateScaleType(view: _view, scaleType: scaleType)
8183
_view.attach(participant: participantObject, stream: mediaStreamObject)
8284
}
85+
86+
private func updateScaleType(view: VTVideoView, scaleType: String?, animated: Bool = false) {
87+
switch scaleType {
88+
case "SCALE_TYPE_FILL":
89+
view.contentFill(true, animated: animated)
90+
case "SCALE_TYPE_FIT":
91+
view.contentFill(false, animated: animated)
92+
default:
93+
break
94+
}
95+
}
8396
}
8497

8598
extension FLVideoView: FlutterBinding {

test_app/integration_tests/ios_mocks/VoxeetSDKMock/Classes/VTVideoView.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@ open class VTVideoView: UIView {
1616
public func unattach() {
1717
fatalError("UnImplemented")
1818
}
19+
20+
public func contentFill(_ fill: Bool, animated: Bool) {
21+
fatalError("UnImplemented")
22+
}
1923
}

0 commit comments

Comments
 (0)