Closed alexfernandojs closed 4 years ago
when you click fullscreen it remains in portrait, you should change it to landscape
Some videos in fullscreen mode requires portrait view like videos taken with the phone camera . So you can listen the player events and detect when the player changes to fullscreen and rotate the device to lanscape mode. See the example to catch the player events.
Do you have an example? because videos I am using all high quality 720p. I just want it when you press fullscreen to be LANDSCAPE. more every time it is portrait. I tried all the ways, strength, for the onfullscreen event. something else makes it come back ..
Just implement the MeeduPlayerEventsMixin an listen when the player changes to fullscreen mode an rotate the device.
landscape mode
SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft,DeviceOrientation.landscapeRight]);
portrait mode
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitDown,DeviceOrientation.portraitUp])
Not work He changes, not even 1 second back to portrait
@override void onPlayerFullScreen(bool isFullScreen) { // TODO: implement onPlayerFullScreen SystemChrome.setPreferredOrientations( [DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight]); }
Not work He changes, not even 1 second back to portrait
@override void onPlayerFullScreen(bool isFullScreen) { // TODO: implement onPlayerFullScreen SystemChrome.setPreferredOrientations( [DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight]); }
I will check this issue
Not work He changes, not even 1 second back to portrait @override void onPlayerFullScreen(bool isFullScreen) { // TODO: implement onPlayerFullScreen SystemChrome.setPreferredOrientations( [DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight]); }
I will check this issue
Please update to version 0.1.1
I think this player is very beautiful. Too bad it doesn't even work. I tried all versions. Squeeze player goes to funsreen continues portrait. pushing through the event he changes sooner back to portrait !!. Funny, this player and a fork was to continue with the video player's standard behavior.
I think this player is very beautiful. Too bad it doesn't even work. I tried all versions. Squeeze player goes to funsreen continues portrait. pushing through the event he changes sooner back to portrait !!. Funny, this player and a fork was to continue with the video player's standard behavior.
please share your code because I tested the app with fullscreen events and every things is ok
CODE USED
`import 'dart:isolate'; import 'dart:ui';
import 'package:anitubeanimeonlinehdefullhd/Model/data.dart'; import 'package:anitubeanimeonlinehdefullhd/main.dart'; import 'package:chewie/chewie.dart'; import 'package:firebase_analytics/firebase_analytics.dart'; import 'package:firebase_analytics/observer.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import 'package:flutter_downloader/flutter_downloader.dart'; import 'package:intent/extra.dart'; import 'package:intent/intent.dart' as android_intent; import 'package:intent/action.dart' as android_action; import 'package:intent/extra.dart' as android_extra; import 'package:intent/category.dart' as android_category; import 'package:mx_player_plugin/mx_player_plugin.dart'; import 'package:path_provider/path_provider.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:screen/screen.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:video_player/video_player.dart'; import "package:anitubeanimeonlinehdefullhd/color.dart"; import 'package:firebase_admob/firebase_admob.dart'; import 'package:http/http.dart' as http; import 'dart:convert'; import 'dart:async'; import 'package:meedu_player/meedu_player.dart';
class Player extends StatefulWidget {
@override
State
final Data data; Player({this.data});
static FirebaseAnalytics analytics = FirebaseAnalytics(); static FirebaseAnalyticsObserver observer = FirebaseAnalyticsObserver(analytics: analytics); }
class PlayerState extends State
int progress = 0;
ReceivePort _receivePort = ReceivePort();
final MeeduPlayerController _controller = MeeduPlayerController(backgroundColor: Color(0xff263238));
_nameRetriever() async { SharedPreferences sessao = await SharedPreferences.getInstance(); setState(() { idusuario = sessao.getString('idusuario');
print("DEBUG:" + idusuario.toString() + " - " + widget.data.toString());
});
_historico(
idusuario, widget.data.vdoname, widget.data.server, widget.data.title);
}
static downloadingCallback(id, status, progress) { ///Looking up for a send port SendPort sendPort = IsolateNameServer.lookupPortByName("downloading");
///ssending the data
sendPort.send([id, status, progress]);
}
static const MobileAdTargetingInfo targetingInfo = MobileAdTargetingInfo(
testDevices: testDevice != null ?
InterstitialAd _interstitialAd; RewardedVideoAd videoAd = RewardedVideoAd.instance; RewardedVideoAd videoAdB = RewardedVideoAd.instance; InterstitialAd createInterstitialAd() { return InterstitialAd( adUnitId: "ca-app-pub-3517514169202811/7823217107", //Change Interstitial AdUnitId with Admob ID targetingInfo: targetingInfo, listener: (MobileAdEvent event) { print("IntersttialAd $event"); }); }
static FirebaseAnalytics analytics = FirebaseAnalytics();
_historico(idusuario, idepisodio, server, titulo) async { var uri = Uri.parse('https://www.animesonline.cx/api2/historico.php'); var request = http.MultipartRequest('POST', uri) ..fields['acao'] = "cadastrar" ..fields['id_usuario'] = idusuario ..fields['id_episodio'] = idepisodio ..fields['server'] = server ..fields['titulo'] = titulo; var resposta = await request.send(); if (resposta.statusCode == 200) {}
print("resposta:" +
idusuario +
" - " +
idepisodio +
" - " +
server +
" - " +
titulo);
}
@override void initState() { _nameRetriever(); SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, ]);
FirebaseAdMob.instance
.initialize(appId: "ca-app-pub-3517514169202811~7811443896");
//Change appId With Admob Id
analytics.setCurrentScreen(screenName: "/Player/" + widget.data.title);
/*
createInterstitialAd()
..load()
..show();
*/
videoAdB.load(
adUnitId: "ca-app-pub-3517514169202811/3459295563",
targetingInfo: targetingInfo);
videoAdB.load(
adUnitId: "ca-app-pub-3517514169202811/3459295563",
targetingInfo: targetingInfo);
videoAdB.listener =
(RewardedVideoAdEvent eventb, {String rewardType, int rewardAmount}) {
print("REWARDED VIDEO AD $eventb");
if (eventb == RewardedVideoAdEvent.closed) {
setState(() {});
print("apost VER O VIDEO !!");
carregaB();
} else {
print("resultado depois");
}
};
print("downloadhd:" + widget.data.downloadhd);
super.initState();
IsolateNameServer.registerPortWithName(
_receivePort.sendPort, "downloading");
///Listening for the data is comming other isolataes
_receivePort.listen((message) {
setState(() {
progress = message[2];
});
print(progress);
});
FlutterDownloader.registerCallback(downloadingCallback);
print("server: " + widget.data.server);
if (widget.data.server == '3') {
sd = widget.data.serverurl +
"sdr2/" +
widget.data.vdoname +
widget.data.tiposerver;
hd = widget.data.serverurl +
"hdr2/" +
widget.data.vdoname +
widget.data.tiposerverhd;
pastasd = "anitubeiphonec";
pastahd = "anitubehd3";
} else {
sd = widget.data.serverurl +
"mobilesd/" +
widget.data.vdoname +
widget.data.tiposerver;
hd = widget.data.serverurl +
"mobilehd/" +
widget.data.vdoname +
widget.data.tiposerverhd;
pastasd = "anitubeiphoneb";
pastahd = "anitubehd2";
}
this._set(sd);
this._controller.events = this;
}
carrega() async { final status = await Permission.storage.request();
if (status.isGranted) {
final externalDir = await getExternalStorageDirectory();
final id = await FlutterDownloader.enqueue(
url: widget.data.downloadsd,
savedDir: externalDir.path,
fileName: "Anitube_SD_" + widget.data.title + ".mp4",
showNotification: true,
openFileFromNotification: true,
);
} else {
print("Permission deined");
}
}
Future
carregaB() async { final status = await Permission.storage.request();
if (status.isGranted) {
final externalDir = await getExternalStorageDirectory();
final id = await FlutterDownloader.enqueue(
url: widget.data.downloadhd,
savedDir: externalDir.path,
fileName: "Anitube_HD_" + widget.data.title + ".mp4",
showNotification: true,
openFileFromNotification: true,
);
} else {
print("Permission deined");
}
}
@override void dispose() { _controller.dispose(); _interstitialAd.dispose(); super.dispose(); }
initPlatformState() async { bool keptOn = await Screen.isKeptOn; setState(() { if (!keptOn) { Screen.keepOn(true); } }); }
@override Widget build(BuildContext context) { initPlatformState();
return MaterialApp(
title: widget.data.title,
theme: ThemeData.light().copyWith(
platform: _platform ?? Theme.of(context).platform,
),
home: Scaffold(
appBar: AppBar(
backgroundColor: '#232222'.toColor(),
title: Text(widget.data.title),
),
body: Center(
child: Container(
color: '#232222'.toColor(),
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(0.0),
child: Container(
child: Column(children: <Widget>[
// START PLAYER VIEW
MeeduPlayer(
controller: _controller,
),
]),
),
),
Row(
children: <Widget>[
const SizedBox(width: 16.0),
Container(
padding: const EdgeInsets.symmetric(
vertical: 0.0,
horizontal: 0.0,
),
child: Center(
child: new ButtonBar(
mainAxisSize: MainAxisSize
.min, // this will take space as minimum as posible(to center)
children: <Widget>[
new RaisedButton(
onPressed: () {
setState(() {});
createInterstitialAd()
..load()
..show();
},
textColor: Colors.white,
child: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: <Color>[
Color(0xFF0D47A1),
Color(0xFF1976D2),
Color(0xFF42A5F5),
],
),
),
padding: const EdgeInsets.all(10.0),
child: Text('Assistir em SD',
style: TextStyle(
color: Colors.white, fontSize: 20)),
),
),
new RaisedButton(
onPressed: () {
setState(() {});
createInterstitialAd()
..load()
..show();
},
textColor: Colors.white,
child: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: <Color>[
Color(0xFF0D47A1),
Color(0xFF1976D2),
Color(0xFF42A5F5),
],
),
),
padding: const EdgeInsets.all(10.0),
child: Text('Assistir em HD',
style: TextStyle(
color: Colors.white,
fontSize: 20,
)),
),
),
],
),
),
)
],
),
Row(
children: <Widget>[
const SizedBox(width: 16.0),
Container(
padding: const EdgeInsets.symmetric(
vertical: 0.0,
horizontal: 0.0,
),
child: Center(
child: new ButtonBar(
mainAxisSize: MainAxisSize
.min, // this will take space as minimum as posible(to center)
children: <Widget>[
new RaisedButton(
onPressed: () async {
//await PlayerPlugin.openWithVlcPlayer(sd);
},
textColor: Colors.white,
child: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: <Color>[
Color(0xFF0D47A1),
Color(0xFF1976D2),
Color(0xFF42A5F5),
],
),
),
padding: const EdgeInsets.all(10.0),
child: Text('Player SD VLC',
style: TextStyle(
color: Colors.white, fontSize: 20)),
),
),
new RaisedButton(
onPressed: () async {
//await PlayerPlugin.openWithVlcPlayer(hd);
},
textColor: Colors.white,
child: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: <Color>[
Color(0xFF0D47A1),
Color(0xFF1976D2),
Color(0xFF42A5F5),
],
),
),
padding: const EdgeInsets.all(10.0),
child: Text('Player HD VLC',
style: TextStyle(
color: Colors.white,
fontSize: 20,
)),
),
),
],
),
),
)
],
),
Row(
children: <Widget>[
const SizedBox(width: 16.0),
Container(
padding: const EdgeInsets.symmetric(
vertical: 0.0,
horizontal: 2.0,
),
child: Center(
child: new ButtonBar(
mainAxisSize: MainAxisSize
.min, // this will take space as minimum as posible(to center)
children: <Widget>[
new RaisedButton(
onPressed: () {
createInterstitialAd()
..load()
..show();
carrega();
},
textColor: Colors.white,
child: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: <Color>[
Color(0xFF0D47A1),
Color(0xFF1976D2),
Color(0xFF42A5F5),
],
),
),
padding: const EdgeInsets.all(10.0),
child: Text('Download SD',
style: TextStyle(
color: Colors.white, fontSize: 20)),
),
),
new RaisedButton(
onPressed: () {
videoAdB.load(
adUnitId:
"ca-app-pub-3517514169202811/3459295563",
targetingInfo: targetingInfo);
videoAdB.show();
},
textColor: Colors.white,
child: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: <Color>[
Color(0xFF0D47A1),
Color(0xFF1976D2),
Color(0xFF42A5F5),
],
),
),
padding: const EdgeInsets.all(10.0),
child: Text('Download HD',
style: TextStyle(
color: Colors.white,
fontSize: 20,
)),
),
),
],
),
),
)
],
),
],
),
),
),
),
);
}
@override void onLauchAsFullScreenStopped() { // TODO: implement onLauchAsFullScreenStopped }
@override void onPlayerError(PlatformException e) { // TODO: implement onPlayerError }
@override void onPlayerFinished() { // TODO: implement onPlayerFinished }
@override void onPlayerFullScreen(bool isFullScreen) { // TODO: implement onPlayerFullScreen SystemChrome.setPreferredOrientations( [DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight]); }
@override void onPlayerLoaded(Duration duration) { // TODO: implement onPlayerLoaded }
@override void onPlayerLoading() { // TODO: implement onPlayerLoading }
@override void onPlayerPaused(Duration position) { // TODO: implement onPlayerPaused }
@override void onPlayerPlaying() { // TODO: implement onPlayerPlaying }
@override void onPlayerPosition(Duration position) { // TODO: implement onPlayerPosition }
@override void onPlayerRepeat() { // TODO: implement onPlayerRepeat }
@override void onPlayerResumed() { // TODO: implement onPlayerResumed }
@override void onPlayerSeekTo(Duration position) { // TODO: implement onPlayerSeekTo } }
@override void onPlayerLoaded(Duration duration) { // TODO: implement onPlayerLoaded }
@override void onPlayerLoading() { // TODO: implement onPlayerLoading }
@override void onPlayerPaused(Duration position) { // TODO: implement onPlayerPaused }
@override void onPlayerPlaying() { // TODO: implement onPlayerPlaying }
@override void onPlayerPosition(Duration position) { // TODO: implement onPlayerPosition }
@override void onPlayerRepeat() { // TODO: implement onPlayerRepeat }
@override void onPlayerResumed() { // TODO: implement onPlayerResumed }
@override void onPlayerSeekTo(Duration position) { // TODO: implement onPlayerSeekTo } `
CODE USED
`import 'dart:isolate'; import 'dart:ui';
import 'package:anitubeanimeonlinehdefullhd/Model/data.dart'; import 'package:anitubeanimeonlinehdefullhd/main.dart'; import 'package:chewie/chewie.dart'; import 'package:firebase_analytics/firebase_analytics.dart'; import 'package:firebase_analytics/observer.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import 'package:flutter_downloader/flutter_downloader.dart'; import 'package:intent/extra.dart'; import 'package:intent/intent.dart' as android_intent; import 'package:intent/action.dart' as android_action; import 'package:intent/extra.dart' as android_extra; import 'package:intent/category.dart' as android_category; import 'package:mx_player_plugin/mx_player_plugin.dart'; import 'package:path_provider/path_provider.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:screen/screen.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:video_player/video_player.dart'; import "package:anitubeanimeonlinehdefullhd/color.dart"; import 'package:firebase_admob/firebase_admob.dart'; import 'package:http/http.dart' as http; import 'dart:convert'; import 'dart:async'; import 'package:meedu_player/meedu_player.dart';
class Player extends StatefulWidget { @override State createState() { return PlayerState(); }
final Data data; Player({this.data});
static FirebaseAnalytics analytics = FirebaseAnalytics(); static FirebaseAnalyticsObserver observer = FirebaseAnalyticsObserver(analytics: analytics); }
class PlayerState extends State with MeeduPlayerEventsMixin { TargetPlatform _platform; VideoPlayerController _videoPlayerController1; ChewieController _chewieController; bool isKeptOn = false; String sd; String hd; int id; String pastasd; String pastahd; String downloadsd; String downloadhd; String idusuario;
int progress = 0;
ReceivePort _receivePort = ReceivePort();
final MeeduPlayerController _controller = MeeduPlayerController(backgroundColor: Color(0xff263238));
_nameRetriever() async { SharedPreferences sessao = await SharedPreferences.getInstance(); setState(() { idusuario = sessao.getString('idusuario');
print("DEBUG:" + idusuario.toString() + " - " + widget.data.toString()); }); _historico( idusuario, widget.data.vdoname, widget.data.server, widget.data.title);
}
static downloadingCallback(id, status, progress) { ///Looking up for a send port SendPort sendPort = IsolateNameServer.lookupPortByName("downloading");
///ssending the data sendPort.send([id, status, progress]);
}
static const MobileAdTargetingInfo targetingInfo = MobileAdTargetingInfo( testDevices: testDevice != null ? [testDevice] : null, nonPersonalizedAds: true, keywords: [ 'Game', 'Cartoon', 'Manga', 'Movie', 'Cinema', 'Jogos', 'Video', 'Anime' ], );
InterstitialAd _interstitialAd; RewardedVideoAd videoAd = RewardedVideoAd.instance; RewardedVideoAd videoAdB = RewardedVideoAd.instance; InterstitialAd createInterstitialAd() { return InterstitialAd( adUnitId: "ca-app-pub-3517514169202811/7823217107", //Change Interstitial AdUnitId with Admob ID targetingInfo: targetingInfo, listener: (MobileAdEvent event) { print("IntersttialAd $event"); }); }
static FirebaseAnalytics analytics = FirebaseAnalytics();
_historico(idusuario, idepisodio, server, titulo) async { var uri = Uri.parse('https://www.animesonline.cx/api2/historico.php'); var request = http.MultipartRequest('POST', uri) ..fields['acao'] = "cadastrar" ..fields['id_usuario'] = idusuario ..fields['id_episodio'] = idepisodio ..fields['server'] = server ..fields['titulo'] = titulo; var resposta = await request.send(); if (resposta.statusCode == 200) {}
print("resposta:" + idusuario + " - " + idepisodio + " - " + server + " - " + titulo);
}
@override void initState() { _nameRetriever(); SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, ]);
FirebaseAdMob.instance .initialize(appId: "ca-app-pub-3517514169202811~7811443896"); //Change appId With Admob Id analytics.setCurrentScreen(screenName: "/Player/" + widget.data.title); /* createInterstitialAd() ..load() ..show(); */ videoAdB.load( adUnitId: "ca-app-pub-3517514169202811/3459295563", targetingInfo: targetingInfo); videoAdB.load( adUnitId: "ca-app-pub-3517514169202811/3459295563", targetingInfo: targetingInfo); videoAdB.listener = (RewardedVideoAdEvent eventb, {String rewardType, int rewardAmount}) { print("REWARDED VIDEO AD $eventb"); if (eventb == RewardedVideoAdEvent.closed) { setState(() {}); print("apost VER O VIDEO !!"); carregaB(); } else { print("resultado depois"); } }; print("downloadhd:" + widget.data.downloadhd); super.initState(); IsolateNameServer.registerPortWithName( _receivePort.sendPort, "downloading"); ///Listening for the data is comming other isolataes _receivePort.listen((message) { setState(() { progress = message[2]; }); print(progress); }); FlutterDownloader.registerCallback(downloadingCallback); print("server: " + widget.data.server); if (widget.data.server == '3') { sd = widget.data.serverurl + "sdr2/" + widget.data.vdoname + widget.data.tiposerver; hd = widget.data.serverurl + "hdr2/" + widget.data.vdoname + widget.data.tiposerverhd; pastasd = "anitubeiphonec"; pastahd = "anitubehd3"; } else { sd = widget.data.serverurl + "mobilesd/" + widget.data.vdoname + widget.data.tiposerver; hd = widget.data.serverurl + "mobilehd/" + widget.data.vdoname + widget.data.tiposerverhd; pastasd = "anitubeiphoneb"; pastahd = "anitubehd2"; } this._set(sd); this._controller.events = this;
}
carrega() async { final status = await Permission.storage.request();
if (status.isGranted) { final externalDir = await getExternalStorageDirectory(); final id = await FlutterDownloader.enqueue( url: widget.data.downloadsd, savedDir: externalDir.path, fileName: "Anitube_SD_" + widget.data.title + ".mp4", showNotification: true, openFileFromNotification: true, ); } else { print("Permission deined"); }
}
Future _set(String source) async { await _controller.setDataSource( dataSource: DataSource( dataSource: source, type: DataSourceType.network, ), autoPlay: true, aspectRatio: 16 / 9, header: Container( padding: EdgeInsets.all(10), child: Text( widget.data.title, style: TextStyle( color: Colors.white, fontWeight: FontWeight.w400, ), ), ), ); }
carregaB() async { final status = await Permission.storage.request();
if (status.isGranted) { final externalDir = await getExternalStorageDirectory(); final id = await FlutterDownloader.enqueue( url: widget.data.downloadhd, savedDir: externalDir.path, fileName: "Anitube_HD_" + widget.data.title + ".mp4", showNotification: true, openFileFromNotification: true, ); } else { print("Permission deined"); }
}
@override void dispose() { _controller.dispose(); _interstitialAd.dispose(); super.dispose(); }
initPlatformState() async { bool keptOn = await Screen.isKeptOn; setState(() { if (!keptOn) { Screen.keepOn(true); } }); }
@override Widget build(BuildContext context) { initPlatformState();
return MaterialApp( title: widget.data.title, theme: ThemeData.light().copyWith( platform: _platform ?? Theme.of(context).platform, ), home: Scaffold( appBar: AppBar( backgroundColor: '#232222'.toColor(), title: Text(widget.data.title), ), body: Center( child: Container( color: '#232222'.toColor(), child: Column( children: <Widget>[ Padding( padding: const EdgeInsets.all(0.0), child: Container( child: Column(children: <Widget>[ // START PLAYER VIEW MeeduPlayer( controller: _controller, ), ]), ), ), Row( children: <Widget>[ const SizedBox(width: 16.0), Container( padding: const EdgeInsets.symmetric( vertical: 0.0, horizontal: 0.0, ), child: Center( child: new ButtonBar( mainAxisSize: MainAxisSize .min, // this will take space as minimum as posible(to center) children: <Widget>[ new RaisedButton( onPressed: () { setState(() {}); createInterstitialAd() ..load() ..show(); }, textColor: Colors.white, child: Container( decoration: const BoxDecoration( gradient: LinearGradient( colors: <Color>[ Color(0xFF0D47A1), Color(0xFF1976D2), Color(0xFF42A5F5), ], ), ), padding: const EdgeInsets.all(10.0), child: Text('Assistir em SD', style: TextStyle( color: Colors.white, fontSize: 20)), ), ), new RaisedButton( onPressed: () { setState(() {}); createInterstitialAd() ..load() ..show(); }, textColor: Colors.white, child: Container( decoration: const BoxDecoration( gradient: LinearGradient( colors: <Color>[ Color(0xFF0D47A1), Color(0xFF1976D2), Color(0xFF42A5F5), ], ), ), padding: const EdgeInsets.all(10.0), child: Text('Assistir em HD', style: TextStyle( color: Colors.white, fontSize: 20, )), ), ), ], ), ), ) ], ), Row( children: <Widget>[ const SizedBox(width: 16.0), Container( padding: const EdgeInsets.symmetric( vertical: 0.0, horizontal: 0.0, ), child: Center( child: new ButtonBar( mainAxisSize: MainAxisSize .min, // this will take space as minimum as posible(to center) children: <Widget>[ new RaisedButton( onPressed: () async { //await PlayerPlugin.openWithVlcPlayer(sd); }, textColor: Colors.white, child: Container( decoration: const BoxDecoration( gradient: LinearGradient( colors: <Color>[ Color(0xFF0D47A1), Color(0xFF1976D2), Color(0xFF42A5F5), ], ), ), padding: const EdgeInsets.all(10.0), child: Text('Player SD VLC', style: TextStyle( color: Colors.white, fontSize: 20)), ), ), new RaisedButton( onPressed: () async { //await PlayerPlugin.openWithVlcPlayer(hd); }, textColor: Colors.white, child: Container( decoration: const BoxDecoration( gradient: LinearGradient( colors: <Color>[ Color(0xFF0D47A1), Color(0xFF1976D2), Color(0xFF42A5F5), ], ), ), padding: const EdgeInsets.all(10.0), child: Text('Player HD VLC', style: TextStyle( color: Colors.white, fontSize: 20, )), ), ), ], ), ), ) ], ), Row( children: <Widget>[ const SizedBox(width: 16.0), Container( padding: const EdgeInsets.symmetric( vertical: 0.0, horizontal: 2.0, ), child: Center( child: new ButtonBar( mainAxisSize: MainAxisSize .min, // this will take space as minimum as posible(to center) children: <Widget>[ new RaisedButton( onPressed: () { createInterstitialAd() ..load() ..show(); carrega(); }, textColor: Colors.white, child: Container( decoration: const BoxDecoration( gradient: LinearGradient( colors: <Color>[ Color(0xFF0D47A1), Color(0xFF1976D2), Color(0xFF42A5F5), ], ), ), padding: const EdgeInsets.all(10.0), child: Text('Download SD', style: TextStyle( color: Colors.white, fontSize: 20)), ), ), new RaisedButton( onPressed: () { videoAdB.load( adUnitId: "ca-app-pub-3517514169202811/3459295563", targetingInfo: targetingInfo); videoAdB.show(); }, textColor: Colors.white, child: Container( decoration: const BoxDecoration( gradient: LinearGradient( colors: <Color>[ Color(0xFF0D47A1), Color(0xFF1976D2), Color(0xFF42A5F5), ], ), ), padding: const EdgeInsets.all(10.0), child: Text('Download HD', style: TextStyle( color: Colors.white, fontSize: 20, )), ), ), ], ), ), ) ], ), ], ), ), ), ), );
}
@override void onLauchAsFullScreenStopped() { // TODO: implement onLauchAsFullScreenStopped }
@override void onPlayerError(PlatformException e) { // TODO: implement onPlayerError }
@override void onPlayerFinished() { // TODO: implement onPlayerFinished }
@override void onPlayerFullScreen(bool isFullScreen) { // TODO: implement onPlayerFullScreen SystemChrome.setPreferredOrientations( [DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight]); }
@override void onPlayerLoaded(Duration duration) { // TODO: implement onPlayerLoaded }
@override void onPlayerLoading() { // TODO: implement onPlayerLoading }
@override void onPlayerPaused(Duration position) { // TODO: implement onPlayerPaused }
@override void onPlayerPlaying() { // TODO: implement onPlayerPlaying }
@override void onPlayerPosition(Duration position) { // TODO: implement onPlayerPosition }
@override void onPlayerRepeat() { // TODO: implement onPlayerRepeat }
@override void onPlayerResumed() { // TODO: implement onPlayerResumed }
@override void onPlayerSeekTo(Duration position) { // TODO: implement onPlayerSeekTo } }
@override void onPlayerLoaded(Duration duration) { // TODO: implement onPlayerLoaded }
@override void onPlayerLoading() { // TODO: implement onPlayerLoading }
@override void onPlayerPaused(Duration position) { // TODO: implement onPlayerPaused }
@override void onPlayerPlaying() { // TODO: implement onPlayerPlaying }
@override void onPlayerPosition(Duration position) { // TODO: implement onPlayerPosition }
@override void onPlayerRepeat() { // TODO: implement onPlayerRepeat }
@override void onPlayerResumed() { // TODO: implement onPlayerResumed }
@override void onPlayerSeekTo(Duration position) { // TODO: implement onPlayerSeekTo } `
Are you sure that you are using the versión 0.1.1?
With the next example and using the version 0.1.1 the landscape mode works fine
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:meedu_player/meedu_player.dart';
final videos = [
'http://clips.vorwaerts-gmbh.de/VfE_html5.mp4',
'http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8',
'https://content.jwplatform.com/manifests/yp34SRmf.m3u8',
'http://www.html5videoplayer.net/videos/toystory.mp4',
'https://html5videoformatconverter.com/data/images/happyfit2.mp4',
'http://playertest.longtailvideo.com/adaptive/bbbfull/bbbfull.m3u8',
];
class NetworkPageDemo extends StatefulWidget {
NetworkPageDemo({Key key}) : super(key: key);
@override
_NetworkPageDemoState createState() => _NetworkPageDemoState();
}
class _NetworkPageDemoState extends State<NetworkPageDemo>
with MeeduPlayerEventsMixin {
final MeeduPlayerController _controller =
MeeduPlayerController(backgroundColor: Colors.black);
@override
void initState() {
super.initState();
this._set(videos[0]);
this._controller.events = this;
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
Future<void> _set(String source) async {
await _controller.setDataSource(
dataSource: DataSource(
dataSource: source,
type: DataSourceType.network,
),
autoPlay: true,
aspectRatio: 16 / 9,
header: Container(
padding: EdgeInsets.all(10),
child: Text(
source,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w400,
),
),
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: SafeArea(
child: Column(
children: <Widget>[
MeeduPlayer(
controller: _controller,
),
Expanded(
child: ListView.builder(
itemBuilder: (_, index) {
return ListTile(
onTap: () {
this._set(videos[index]);
},
title: Text("View video ${index + 1}"),
);
},
itemCount: videos.length,
),
)
],
),
),
);
}
@override
void onPlayerError(PlatformException e) {}
@override
void onPlayerFinished() {}
@override
void onPlayerFullScreen(bool isFullScreen) {
if (isFullScreen) {
SystemChrome.setPreferredOrientations([
DeviceOrientation.landscapeLeft,
DeviceOrientation.landscapeRight,
]);
} else {
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
}
}
@override
void onPlayerLoaded(Duration duration) {}
@override
void onPlayerLoading() {}
@override
void onPlayerPaused(Duration position) {}
@override
void onPlayerPlaying() {}
@override
void onPlayerRepeat() {}
@override
void onPlayerResumed() {}
@override
void onPlayerSeekTo(Duration position) {}
@override
void onPlayerPosition(Duration position) {}
@override
void onLauchAsFullScreenStopped() {}
}
CODE USED `import 'dart:isolate'; import 'dart:ui'; import 'package:anitubeanimeonlinehdefullhd/Model/data.dart'; import 'package:anitubeanimeonlinehdefullhd/main.dart'; import 'package:chewie/chewie.dart'; import 'package:firebase_analytics/firebase_analytics.dart'; import 'package:firebase_analytics/observer.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import 'package:flutter_downloader/flutter_downloader.dart'; import 'package:intent/extra.dart'; import 'package:intent/intent.dart' as android_intent; import 'package:intent/action.dart' as android_action; import 'package:intent/extra.dart' as android_extra; import 'package:intent/category.dart' as android_category; import 'package:mx_player_plugin/mx_player_plugin.dart'; import 'package:path_provider/path_provider.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:screen/screen.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:video_player/video_player.dart'; import "package:anitubeanimeonlinehdefullhd/color.dart"; import 'package:firebase_admob/firebase_admob.dart'; import 'package:http/http.dart' as http; import 'dart:convert'; import 'dart:async'; import 'package:meedu_player/meedu_player.dart'; class Player extends StatefulWidget { @override State createState() { return PlayerState(); } final Data data; Player({this.data}); static FirebaseAnalytics analytics = FirebaseAnalytics(); static FirebaseAnalyticsObserver observer = FirebaseAnalyticsObserver(analytics: analytics); } class PlayerState extends State with MeeduPlayerEventsMixin { TargetPlatform _platform; VideoPlayerController _videoPlayerController1; ChewieController _chewieController; bool isKeptOn = false; String sd; String hd; int id; String pastasd; String pastahd; String downloadsd; String downloadhd; String idusuario; int progress = 0; ReceivePort _receivePort = ReceivePort(); final MeeduPlayerController _controller = MeeduPlayerController(backgroundColor: Color(0xff263238)); _nameRetriever() async { SharedPreferences sessao = await SharedPreferences.getInstance(); setState(() { idusuario = sessao.getString('idusuario');
print("DEBUG:" + idusuario.toString() + " - " + widget.data.toString()); }); _historico( idusuario, widget.data.vdoname, widget.data.server, widget.data.title);
} static downloadingCallback(id, status, progress) { ///Looking up for a send port SendPort sendPort = IsolateNameServer.lookupPortByName("downloading");
///ssending the data sendPort.send([id, status, progress]);
} static const MobileAdTargetingInfo targetingInfo = MobileAdTargetingInfo( testDevices: testDevice != null ? [testDevice] : null, nonPersonalizedAds: true, keywords: [ 'Game', 'Cartoon', 'Manga', 'Movie', 'Cinema', 'Jogos', 'Video', 'Anime' ], ); InterstitialAd _interstitialAd; RewardedVideoAd videoAd = RewardedVideoAd.instance; RewardedVideoAd videoAdB = RewardedVideoAd.instance; InterstitialAd createInterstitialAd() { return InterstitialAd( adUnitId: "ca-app-pub-3517514169202811/7823217107", //Change Interstitial AdUnitId with Admob ID targetingInfo: targetingInfo, listener: (MobileAdEvent event) { print("IntersttialAd $event"); }); } static FirebaseAnalytics analytics = FirebaseAnalytics(); _historico(idusuario, idepisodio, server, titulo) async { var uri = Uri.parse('https://www.animesonline.cx/api2/historico.php'); var request = http.MultipartRequest('POST', uri) ..fields['acao'] = "cadastrar" ..fields['id_usuario'] = idusuario ..fields['id_episodio'] = idepisodio ..fields['server'] = server ..fields['titulo'] = titulo; var resposta = await request.send(); if (resposta.statusCode == 200) {}
print("resposta:" + idusuario + " - " + idepisodio + " - " + server + " - " + titulo);
} @override void initState() { _nameRetriever(); SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, ]);
FirebaseAdMob.instance .initialize(appId: "ca-app-pub-3517514169202811~7811443896"); //Change appId With Admob Id analytics.setCurrentScreen(screenName: "/Player/" + widget.data.title); /* createInterstitialAd() ..load() ..show(); */ videoAdB.load( adUnitId: "ca-app-pub-3517514169202811/3459295563", targetingInfo: targetingInfo); videoAdB.load( adUnitId: "ca-app-pub-3517514169202811/3459295563", targetingInfo: targetingInfo); videoAdB.listener = (RewardedVideoAdEvent eventb, {String rewardType, int rewardAmount}) { print("REWARDED VIDEO AD $eventb"); if (eventb == RewardedVideoAdEvent.closed) { setState(() {}); print("apost VER O VIDEO !!"); carregaB(); } else { print("resultado depois"); } }; print("downloadhd:" + widget.data.downloadhd); super.initState(); IsolateNameServer.registerPortWithName( _receivePort.sendPort, "downloading"); ///Listening for the data is comming other isolataes _receivePort.listen((message) { setState(() { progress = message[2]; }); print(progress); }); FlutterDownloader.registerCallback(downloadingCallback); print("server: " + widget.data.server); if (widget.data.server == '3') { sd = widget.data.serverurl + "sdr2/" + widget.data.vdoname + widget.data.tiposerver; hd = widget.data.serverurl + "hdr2/" + widget.data.vdoname + widget.data.tiposerverhd; pastasd = "anitubeiphonec"; pastahd = "anitubehd3"; } else { sd = widget.data.serverurl + "mobilesd/" + widget.data.vdoname + widget.data.tiposerver; hd = widget.data.serverurl + "mobilehd/" + widget.data.vdoname + widget.data.tiposerverhd; pastasd = "anitubeiphoneb"; pastahd = "anitubehd2"; } this._set(sd); this._controller.events = this;
} carrega() async { final status = await Permission.storage.request();
if (status.isGranted) { final externalDir = await getExternalStorageDirectory(); final id = await FlutterDownloader.enqueue( url: widget.data.downloadsd, savedDir: externalDir.path, fileName: "Anitube_SD_" + widget.data.title + ".mp4", showNotification: true, openFileFromNotification: true, ); } else { print("Permission deined"); }
} Future _set(String source) async { await _controller.setDataSource( dataSource: DataSource( dataSource: source, type: DataSourceType.network, ), autoPlay: true, aspectRatio: 16 / 9, header: Container( padding: EdgeInsets.all(10), child: Text( widget.data.title, style: TextStyle( color: Colors.white, fontWeight: FontWeight.w400, ), ), ), ); } carregaB() async { final status = await Permission.storage.request();
if (status.isGranted) { final externalDir = await getExternalStorageDirectory(); final id = await FlutterDownloader.enqueue( url: widget.data.downloadhd, savedDir: externalDir.path, fileName: "Anitube_HD_" + widget.data.title + ".mp4", showNotification: true, openFileFromNotification: true, ); } else { print("Permission deined"); }
} @override void dispose() { _controller.dispose(); _interstitialAd.dispose(); super.dispose(); } initPlatformState() async { bool keptOn = await Screen.isKeptOn; setState(() { if (!keptOn) { Screen.keepOn(true); } }); } @override Widget build(BuildContext context) { initPlatformState();
return MaterialApp( title: widget.data.title, theme: ThemeData.light().copyWith( platform: _platform ?? Theme.of(context).platform, ), home: Scaffold( appBar: AppBar( backgroundColor: '#232222'.toColor(), title: Text(widget.data.title), ), body: Center( child: Container( color: '#232222'.toColor(), child: Column( children: <Widget>[ Padding( padding: const EdgeInsets.all(0.0), child: Container( child: Column(children: <Widget>[ // START PLAYER VIEW MeeduPlayer( controller: _controller, ), ]), ), ), Row( children: <Widget>[ const SizedBox(width: 16.0), Container( padding: const EdgeInsets.symmetric( vertical: 0.0, horizontal: 0.0, ), child: Center( child: new ButtonBar( mainAxisSize: MainAxisSize .min, // this will take space as minimum as posible(to center) children: <Widget>[ new RaisedButton( onPressed: () { setState(() {}); createInterstitialAd() ..load() ..show(); }, textColor: Colors.white, child: Container( decoration: const BoxDecoration( gradient: LinearGradient( colors: <Color>[ Color(0xFF0D47A1), Color(0xFF1976D2), Color(0xFF42A5F5), ], ), ), padding: const EdgeInsets.all(10.0), child: Text('Assistir em SD', style: TextStyle( color: Colors.white, fontSize: 20)), ), ), new RaisedButton( onPressed: () { setState(() {}); createInterstitialAd() ..load() ..show(); }, textColor: Colors.white, child: Container( decoration: const BoxDecoration( gradient: LinearGradient( colors: <Color>[ Color(0xFF0D47A1), Color(0xFF1976D2), Color(0xFF42A5F5), ], ), ), padding: const EdgeInsets.all(10.0), child: Text('Assistir em HD', style: TextStyle( color: Colors.white, fontSize: 20, )), ), ), ], ), ), ) ], ), Row( children: <Widget>[ const SizedBox(width: 16.0), Container( padding: const EdgeInsets.symmetric( vertical: 0.0, horizontal: 0.0, ), child: Center( child: new ButtonBar( mainAxisSize: MainAxisSize .min, // this will take space as minimum as posible(to center) children: <Widget>[ new RaisedButton( onPressed: () async { //await PlayerPlugin.openWithVlcPlayer(sd); }, textColor: Colors.white, child: Container( decoration: const BoxDecoration( gradient: LinearGradient( colors: <Color>[ Color(0xFF0D47A1), Color(0xFF1976D2), Color(0xFF42A5F5), ], ), ), padding: const EdgeInsets.all(10.0), child: Text('Player SD VLC', style: TextStyle( color: Colors.white, fontSize: 20)), ), ), new RaisedButton( onPressed: () async { //await PlayerPlugin.openWithVlcPlayer(hd); }, textColor: Colors.white, child: Container( decoration: const BoxDecoration( gradient: LinearGradient( colors: <Color>[ Color(0xFF0D47A1), Color(0xFF1976D2), Color(0xFF42A5F5), ], ), ), padding: const EdgeInsets.all(10.0), child: Text('Player HD VLC', style: TextStyle( color: Colors.white, fontSize: 20, )), ), ), ], ), ), ) ], ), Row( children: <Widget>[ const SizedBox(width: 16.0), Container( padding: const EdgeInsets.symmetric( vertical: 0.0, horizontal: 2.0, ), child: Center( child: new ButtonBar( mainAxisSize: MainAxisSize .min, // this will take space as minimum as posible(to center) children: <Widget>[ new RaisedButton( onPressed: () { createInterstitialAd() ..load() ..show(); carrega(); }, textColor: Colors.white, child: Container( decoration: const BoxDecoration( gradient: LinearGradient( colors: <Color>[ Color(0xFF0D47A1), Color(0xFF1976D2), Color(0xFF42A5F5), ], ), ), padding: const EdgeInsets.all(10.0), child: Text('Download SD', style: TextStyle( color: Colors.white, fontSize: 20)), ), ), new RaisedButton( onPressed: () { videoAdB.load( adUnitId: "ca-app-pub-3517514169202811/3459295563", targetingInfo: targetingInfo); videoAdB.show(); }, textColor: Colors.white, child: Container( decoration: const BoxDecoration( gradient: LinearGradient( colors: <Color>[ Color(0xFF0D47A1), Color(0xFF1976D2), Color(0xFF42A5F5), ], ), ), padding: const EdgeInsets.all(10.0), child: Text('Download HD', style: TextStyle( color: Colors.white, fontSize: 20, )), ), ), ], ), ), ) ], ), ], ), ), ), ), );
} @override void onLauchAsFullScreenStopped() { // TODO: implement onLauchAsFullScreenStopped } @override void onPlayerError(PlatformException e) { // TODO: implement onPlayerError } @override void onPlayerFinished() { // TODO: implement onPlayerFinished } @override void onPlayerFullScreen(bool isFullScreen) { // TODO: implement onPlayerFullScreen SystemChrome.setPreferredOrientations( [DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight]); } @override void onPlayerLoaded(Duration duration) { // TODO: implement onPlayerLoaded } @override void onPlayerLoading() { // TODO: implement onPlayerLoading } @override void onPlayerPaused(Duration position) { // TODO: implement onPlayerPaused } @override void onPlayerPlaying() { // TODO: implement onPlayerPlaying } @override void onPlayerPosition(Duration position) { // TODO: implement onPlayerPosition } @override void onPlayerRepeat() { // TODO: implement onPlayerRepeat } @override void onPlayerResumed() { // TODO: implement onPlayerResumed } @override void onPlayerSeekTo(Duration position) { // TODO: implement onPlayerSeekTo } } @override void onPlayerLoaded(Duration duration) { // TODO: implement onPlayerLoaded } @override void onPlayerLoading() { // TODO: implement onPlayerLoading } @override void onPlayerPaused(Duration position) { // TODO: implement onPlayerPaused } @override void onPlayerPlaying() { // TODO: implement onPlayerPlaying } @override void onPlayerPosition(Duration position) { // TODO: implement onPlayerPosition } @override void onPlayerRepeat() { // TODO: implement onPlayerRepeat } @override void onPlayerResumed() { // TODO: implement onPlayerResumed } @override void onPlayerSeekTo(Duration position) { // TODO: implement onPlayerSeekTo } `
Are you sure that you are using the versión 0.1.1?
With the next example and using the version 0.1.1 the landscape mode works fine
import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:meedu_player/meedu_player.dart'; final videos = [ 'http://clips.vorwaerts-gmbh.de/VfE_html5.mp4', 'http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8', 'https://content.jwplatform.com/manifests/yp34SRmf.m3u8', 'http://www.html5videoplayer.net/videos/toystory.mp4', 'https://html5videoformatconverter.com/data/images/happyfit2.mp4', 'http://playertest.longtailvideo.com/adaptive/bbbfull/bbbfull.m3u8', ]; class NetworkPageDemo extends StatefulWidget { NetworkPageDemo({Key key}) : super(key: key); @override _NetworkPageDemoState createState() => _NetworkPageDemoState(); } class _NetworkPageDemoState extends State<NetworkPageDemo> with MeeduPlayerEventsMixin { final MeeduPlayerController _controller = MeeduPlayerController(backgroundColor: Colors.black); @override void initState() { super.initState(); this._set(videos[0]); this._controller.events = this; // <--- call just one time } @override void dispose() { _controller.dispose(); super.dispose(); } Future<void> _set(String source) async { await _controller.setDataSource( dataSource: DataSource( dataSource: source, type: DataSourceType.network, ), autoPlay: true, aspectRatio: 16 / 9, header: Container( padding: EdgeInsets.all(10), child: Text( source, style: TextStyle( color: Colors.white, fontWeight: FontWeight.w400, ), ), ), ); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(), body: SafeArea( child: Column( children: <Widget>[ MeeduPlayer( controller: _controller, ), Expanded( child: ListView.builder( itemBuilder: (_, index) { return ListTile( onTap: () { this._set(videos[index]); }, title: Text("View video ${index + 1}"), ); }, itemCount: videos.length, ), ) ], ), ), ); } @override void onPlayerError(PlatformException e) {} @override void onPlayerFinished() {} @override void onPlayerFullScreen(bool isFullScreen) { if (isFullScreen) { SystemChrome.setPreferredOrientations([ DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight, ]); } else { SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, DeviceOrientation.portraitDown, ]); } } @override void onPlayerLoaded(Duration duration) {} @override void onPlayerLoading() {} @override void onPlayerPaused(Duration position) {} @override void onPlayerPlaying() {} @override void onPlayerRepeat() {} @override void onPlayerResumed() {} @override void onPlayerSeekTo(Duration position) {} @override void onPlayerPosition(Duration position) {} @override void onLauchAsFullScreenStopped() {} }
https://prnt.sc/tmyjw1 Same behavior continues.
Fixed on 0.2.0
when you click fullscreen it remains in portrait, you should change it to landscape