Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[video_player_avplay] Add setDisplayMode and setDisplayRotate API #789

Merged

Conversation

xiaowei-guan
Copy link
Contributor

/// Set the rotate angle of display
  Future<bool> setDisplayRotate(DisplayRotation rotation)
/// Set the video display mode.
  Future<bool> setDisplayMode(DisplayMode displayMode)

@JSUYA
Copy link
Member

JSUYA commented Dec 27, 2024

I tested the setDisplayRotate() API, but there was no change in the video output.
Are there any order or option(?) on using the API?

--- a/packages/video_player_avplay/example/lib/main.dart
+++ b/packages/video_player_avplay/example/lib/main.dart
@@ -80,6 +80,7 @@ class _HlsRomoteVideoState extends State<_HlsRomoteVideo> {
       }
       setState(() {});
     });
+    _controller.setDisplayRotate(DisplayRotation.rotation_180);
     _controller.setLooping(true);
     _controller.initialize().then((_) => setState(() {}));
     _controller.play();
@@ -202,6 +203,7 @@ class _Mp4RemoteVideoState extends State<_Mp4RemoteVideo> {
       }
       setState(() {});
     });
+    _controller.setDisplayRotate(DisplayRotation.rotation_90);
     _controller.setLooping(true);
     _controller.initialize().then((_) => setState(() {}));
     _controller.play();

@xiaowei-guan
Copy link
Contributor Author

I tested the setDisplayRotate() API, but there was no change in the video output. Are there any order or option(?) on using the API?

--- a/packages/video_player_avplay/example/lib/main.dart
+++ b/packages/video_player_avplay/example/lib/main.dart
@@ -80,6 +80,7 @@ class _HlsRomoteVideoState extends State<_HlsRomoteVideo> {
       }
       setState(() {});
     });
+    _controller.setDisplayRotate(DisplayRotation.rotation_180);
     _controller.setLooping(true);
     _controller.initialize().then((_) => setState(() {}));
     _controller.play();
@@ -202,6 +203,7 @@ class _Mp4RemoteVideoState extends State<_Mp4RemoteVideo> {
       }
       setState(() {});
     });
+    _controller.setDisplayRotate(DisplayRotation.rotation_90);
     _controller.setLooping(true);
     _controller.initialize().then((_) => setState(() {}));
     _controller.play();

Future _checkAndUpdateVideoRotate() async {
final int? rotate = await windowChannel.invokeMethod('getRotation');
print('rotate $rotate');
if (rotate == 90) {
await _controller.setDisplayRotate(DisplayRotation.rotation_270);
} else if (rotate == 180) {
await _controller.setDisplayRotate(DisplayRotation.rotation_180);
} else if (rotate == 270) {
await _controller.setDisplayRotate(DisplayRotation.rotation_90);
} else {
await _controller.setDisplayRotate(DisplayRotation.rotation_0);
}
}

Need convert screen degree to video degree.

@JSUYA
Copy link
Member

JSUYA commented Dec 27, 2024

I tested the setDisplayRotate() API, but there was no change in the video output. Are there any order or option(?) on using the API?

--- a/packages/video_player_avplay/example/lib/main.dart
+++ b/packages/video_player_avplay/example/lib/main.dart
@@ -80,6 +80,7 @@ class _HlsRomoteVideoState extends State<_HlsRomoteVideo> {
       }
       setState(() {});
     });
+    _controller.setDisplayRotate(DisplayRotation.rotation_180);
     _controller.setLooping(true);
     _controller.initialize().then((_) => setState(() {}));
     _controller.play();
@@ -202,6 +203,7 @@ class _Mp4RemoteVideoState extends State<_Mp4RemoteVideo> {
       }
       setState(() {});
     });
+    _controller.setDisplayRotate(DisplayRotation.rotation_90);
     _controller.setLooping(true);
     _controller.initialize().then((_) => setState(() {}));
     _controller.play();

Future _checkAndUpdateVideoRotate() async { final int? rotate = await windowChannel.invokeMethod('getRotation'); print('rotate $rotate'); if (rotate == 90) { await _controller.setDisplayRotate(DisplayRotation.rotation_270); } else if (rotate == 180) { await _controller.setDisplayRotate(DisplayRotation.rotation_180); } else if (rotate == 270) { await _controller.setDisplayRotate(DisplayRotation.rotation_90); } else { await _controller.setDisplayRotate(DisplayRotation.rotation_0); } }

Need convert screen degree to video degree.

thanks i tested with flutter-tizen/embedder#79

But why is setDisplayMode() needed? Should all items in enum DisplayMode be supported?

@xiaowei-guan
Copy link
Contributor Author

I tested the setDisplayRotate() API, but there was no change in the video output. Are there any order or option(?) on using the API?

--- a/packages/video_player_avplay/example/lib/main.dart
+++ b/packages/video_player_avplay/example/lib/main.dart
@@ -80,6 +80,7 @@ class _HlsRomoteVideoState extends State<_HlsRomoteVideo> {
       }
       setState(() {});
     });
+    _controller.setDisplayRotate(DisplayRotation.rotation_180);
     _controller.setLooping(true);
     _controller.initialize().then((_) => setState(() {}));
     _controller.play();
@@ -202,6 +203,7 @@ class _Mp4RemoteVideoState extends State<_Mp4RemoteVideo> {
       }
       setState(() {});
     });
+    _controller.setDisplayRotate(DisplayRotation.rotation_90);
     _controller.setLooping(true);
     _controller.initialize().then((_) => setState(() {}));
     _controller.play();

Future _checkAndUpdateVideoRotate() async { final int? rotate = await windowChannel.invokeMethod('getRotation'); print('rotate $rotate'); if (rotate == 90) { await _controller.setDisplayRotate(DisplayRotation.rotation_270); } else if (rotate == 180) { await _controller.setDisplayRotate(DisplayRotation.rotation_180); } else if (rotate == 270) { await _controller.setDisplayRotate(DisplayRotation.rotation_90); } else { await _controller.setDisplayRotate(DisplayRotation.rotation_0); } }
Need convert screen degree to video degree.

thanks i tested with flutter-tizen/embedder#79

But why is setDisplayMode() needed? Should all items in enum DisplayMode be supported?

app can set the video screen mode in the specified display area.
If orentation is changed, app can call setDisplayMode method, it all depends app side.
Web avplay only supports : "PLAYER_DISPLAY_MODE_LETTER_BOX", "PLAYER_DISPLAY_MODE_FULL_SCREEN", or "PLAYER_DISPLAY_MODE_AUTO_ASPECT_RATIO"
https://developer.samsung.com/smarttv/develop/api-references/samsung-product-api-references/avplay-api.html#AVPlayManager-setDisplayMethod

@xiaowei-guan xiaowei-guan merged commit 5b0f1ed into flutter-tizen:master Dec 30, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants