Closed armanhadifatah closed 1 year ago
ok will test and let know
Hello dear
I have this code
final _meeduPlayerController = MeeduPlayerController( controlsStyle: ControlsStyle.secondary, fits: [BoxFit.contain], screenManager: ScreenManager( forceLandScapeInFullscreen: true, ), manageWakeLock: true, onVideoPlayerClosed: () => {}, );
And for the first time when i press full screen button on the player it will not open in landscape its portrait but after I go back and then press full screen it will work and be in landScape
its working for me, on what platform are testing and what package version?
can you test on last version? and if still happens can you provide the full page?
This is the entire code of my player class
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_meedu_videoplayer/meedu_player.dart';
import 'package:wakelock/wakelock.dart';
class BasicMeeduPlayer extends StatefulWidget {
final String videoUrl;
final Function(int position) onClose;
final double? lastPosition;
const BasicMeeduPlayer({
Key? key,
required this.videoUrl,
required this.onClose,
this.lastPosition,
}) : super(key: key);
@override
_BasicMeeduPlayerState createState() => _BasicMeeduPlayerState();
}
class _BasicMeeduPlayerState extends State<BasicMeeduPlayer> {
final _meeduPlayerController = MeeduPlayerController(
controlsStyle: ControlsStyle.secondary,
fits: [BoxFit.contain],
screenManager: ScreenManager(forceLandScapeInFullscreen: true),
);
StreamSubscription? _playerEventSubs;
int? currentPosition;
@override
void initState() {
super.initState();
Wakelock.enable();
_init();
}
@override
void dispose() {
currentPosition =
_meeduPlayerController.videoPlayerController!.value.position.inSeconds;
widget.onClose(currentPosition ?? 0);
_playerEventSubs?.cancel();
_meeduPlayerController.dispose();
Wakelock.disable();
super.dispose();
}
void _init() {
_meeduPlayerController.setDataSource(
DataSource(
type: DataSourceType.network,
formatHint: VideoFormat.hls,
source: widget.videoUrl,
),
seekTo: Duration(seconds: widget.lastPosition?.toInt() ?? 0),
autoplay: true,
);
}
@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
return Container(
width: size.width,
height: size.width * (9 / 16),
child: Directionality(
textDirection: TextDirection.ltr,
child: AspectRatio(
aspectRatio: 16 / 9,
child: MeeduVideoPlayer(
controller: _meeduPlayerController,
),
),
),
);
}
}
I'm using Flutter 3.7.11 flutter_meedu_videoplayer: 4.1.0 media_kit: ^0.0.4+1 media_kit_video: ^0.0.4 media_kit_libs_ios_video: ^1.0.3
This is on IOS
But the problem is just for the first time i open the app and the player after that it will work fine
An other problem is if i'm in portrait when i exit the full screen it will not change the app to go back to portrait it will stick to landscape so i must move my phone to landscape and portrait again to make it right .
I solved this issue by the following code
_meeduPlayerController.onFullscreenChanged.listen((event) {
if (!event) {
// change app orientation to portrait
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
]);
} else {
// change app orientation to landscape
SystemChrome.setPreferredOrientations([
DeviceOrientation.landscapeLeft,
DeviceOrientation.landscapeRight,
]);
}
});
sadly i cant test on ios, so can you check the package code and create a pr for the fix?
also are you on ios 16?
and does the first time show any errors?
Sure i will check the package code if i could fix it will do a pr I'm using ios 15.7.3
Sure i will check the package code if i could fix it will do a pr I'm using ios 15.7.3
thank you, can you also test the auto orientation example? since it uses a diffrent package than the package so if its works its a problem with auto_orientation
This is the entire code of my player class
import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_meedu_videoplayer/meedu_player.dart'; import 'package:wakelock/wakelock.dart'; class BasicMeeduPlayer extends StatefulWidget { final String videoUrl; final Function(int position) onClose; final double? lastPosition; const BasicMeeduPlayer({ Key? key, required this.videoUrl, required this.onClose, this.lastPosition, }) : super(key: key); @override _BasicMeeduPlayerState createState() => _BasicMeeduPlayerState(); } class _BasicMeeduPlayerState extends State<BasicMeeduPlayer> { final _meeduPlayerController = MeeduPlayerController( controlsStyle: ControlsStyle.secondary, fits: [BoxFit.contain], screenManager: ScreenManager(forceLandScapeInFullscreen: true), ); StreamSubscription? _playerEventSubs; int? currentPosition; @override void initState() { super.initState(); Wakelock.enable(); _init(); } @override void dispose() { currentPosition = _meeduPlayerController.videoPlayerController!.value.position.inSeconds; widget.onClose(currentPosition ?? 0); _playerEventSubs?.cancel(); _meeduPlayerController.dispose(); Wakelock.disable(); super.dispose(); } void _init() { _meeduPlayerController.setDataSource( DataSource( type: DataSourceType.network, formatHint: VideoFormat.hls, source: widget.videoUrl, ), seekTo: Duration(seconds: widget.lastPosition?.toInt() ?? 0), autoplay: true, ); } @override Widget build(BuildContext context) { final size = MediaQuery.of(context).size; return Container( width: size.width, height: size.width * (9 / 16), child: Directionality( textDirection: TextDirection.ltr, child: AspectRatio( aspectRatio: 16 / 9, child: MeeduVideoPlayer( controller: _meeduPlayerController, ), ), ), ); } }
I'm using Flutter 3.7.11 flutter_meedu_videoplayer: 4.1.0 media_kit: ^0.0.4+1 media_kit_video: ^0.0.4 media_kit_libs_ios_video: ^1.0.3
This is on IOS
But the problem is just for the first time i open the app and the player after that it will work fine
An other problem is if i'm in portrait when i exit the full screen it will not change the app to go back to portrait it will stick to landscape so i must move my phone to landscape and portrait again to make it right .
I solved this issue by the following code
_meeduPlayerController.onFullscreenChanged.listen((event) { if (!event) { // change app orientation to portrait SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, ]); } else { // change app orientation to landscape SystemChrome.setPreferredOrientations([ DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight, ]); } });
Can you try this code, without your full screen listener?
Just to make sure where is the problem
https://github.com/bytepark/auto_orientation/pull/31 also i am waiting for this pull request, since it should use swift and support ios 16. so will see what it can fix
@armanhadifatah can you test on flutter_meedu_videoplayer: ^4.2.4
it should be fixed since the pr was merged
4.2.11-dev-2 fixed
Hello dear
I have this code
And for the first time when i press full screen button on the player it will not open in landscape its portrait but after I go back and then press full screen it will work and be in landScape