Comments (3)
can you make a reproducible code, and what is the platform you are using? and device?
in general give us as much information as possible so we pinpoint the issue and if its fixable from our end, or wakelock themselves
from media-kit.
can you make a reproducible code, and what is the platform you are using? and device? in general give us as much information as possible so we pinpoint the issue and if its fixable from our end, or wakelock themselves
This is my code, i have tested on Android, everything works fine but the wakelock doesn't work. As for the device, I use a Samsung s23 for the test.
` import 'dart:async';
import 'package:animeTv/models/episode_page.dart';
import 'package:animeTv/screens/video-player/fullscreen_episodes_screen.dart';
import 'package:animeTv/util/constants.dart';
import 'package:animeTv/widgets/custom-player/base_player.dart';
import "package:flutter/material.dart";
import 'package:flutter/services.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:media_kit/media_kit.dart';
import 'package:media_kit_video/media_kit_video.dart';
class CustomPlayer extends StatefulWidget {
final GlobalKey<VideoState> videoKey;
final VideoController controller;
final bool fromDownload;
final EpisodePage? episode;
final Function callback;
final int initialPosition;
final VoidCallback nextEpisode;
final Function(String episodeLink) startEpisode;
final List<EpisodeInList>? episodes;
const CustomPlayer({
super.key,
required this.videoKey,
required this.controller,
required this.fromDownload,
required this.episode,
required this.callback,
required this.initialPosition,
required this.nextEpisode,
required this.startEpisode,
this.episodes,
});
@override
State<CustomPlayer> createState() => _CustomPlayerState();
}
class _CustomPlayerState extends State<CustomPlayer> {
bool hasLoaded = false;
bool hasError = false;
void initController() {
if (!widget.fromDownload) {
widget.controller.player.stream.position.listen(
(Duration position) {
widget.callback(position);
},
);
}
}
void loadVideo(Duration position, String url) async {
await widget.controller.player.open(Media(url));
widget.controller.player.stream.duration.listen((event) async {
if (event.inSeconds > 0) {
await widget.controller.player.seek(position);
}
});
}
void _moveSeconds(String moveType) async {
final currentDuration = widget.controller.player.state.position;
//aggiungo o sottraggo 10 secondi alla durata iniziale
final newDuration =
currentDuration + Duration(seconds: moveType == "forward" ? 10 : -10);
await widget.controller.player.seek(newDuration);
}
void _onClosePlayer() {
//se sono nei download chiudo la pagina completamente e torno a quella precedente
if (widget.fromDownload) {
Navigator.of(context).popUntil((route) => route.isFirst);
} else {
Constants.navigatorKey.currentState?.pop();
}
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: [SystemUiOverlay.top, SystemUiOverlay.bottom]);
}
void _openEpisodes() {
widget.controller.player.pause();
Constants.navigatorKey.currentState!
.push(MaterialPageRoute(builder: (context) {
return FullscreenEpisodesScreen(
allEpisodes: widget.episodes!,
startEpisode: (String episodeLink) {
widget.startEpisode(episodeLink);
},
onClose: () {
widget.controller.player.play();
},
);
}));
}
Future<void> initPlayer({
required Duration position,
}) async {
loadVideo(position, widget.episode!.videoUrl);
}
initAll() async {
initController();
initPlayer(position: Duration(seconds: widget.initialPosition));
setState(() {
hasLoaded = true;
});
}
@override
void initState() {
initAll();
super.initState();
}
@override
Widget build(BuildContext context) {
return BasePlayer(
controller: widget.controller,
nextEpisode: widget.nextEpisode,
moveSeconds: (String type) {
_moveSeconds(type);
},
onClosePlayer: () {
_onClosePlayer();
},
openEpisodes: widget.episodes != null ? _openEpisodes : null,
fromDownload: widget.fromDownload,
body: hasError
? Container(
alignment: Alignment.center,
color: Theme.of(context).colorScheme.background,
child: const Text(
"Sembra che il video sia ancora in fase di elaborazione,\n riprova più tardi",
textAlign: TextAlign.center,
),
)
: hasLoaded
? Video(
key: widget.videoKey,
controller: widget.controller,
controls: MaterialVideoControls,
onEnterFullscreen: () async {
await defaultEnterNativeFullscreen();
},
onExitFullscreen: () async {
_onClosePlayer();
},
)
: Flexible(
child: Center(
child: SpinKitThreeInOut(
color: Theme.of(context).colorScheme.primary,
size: 30,
),
),
),
);
}
}`
from media-kit.
Please give a test code with the problem that I can run,
Better question what are you testing on and does the problem happen on the example app? If not then it's a problem on your side check that you don't disable wake lock by mistake
from media-kit.
Related Issues (20)
- Exclude support for unused codecs HOT 1
- url not play HOT 1
- Can't auto-play video from a flutter web app HOT 2
- Performance Advice Windows
- [Feature request] Transition builder/Hero animation for fullscreen route
- Crashes on linux - seems related to VideoController? HOT 8
- Replace js dependency with web for WASM compilation HOT 1
- Error Screen HOT 1
- Can not Find Header When Add to Existing IOS App Using Module Way HOT 1
- Crash/Freeze on Windows HOT 8
- Not possible to initialise MediaKit when running widget tests HOT 4
- App crash after 1~2 seconds of playing a video on linux. HOT 2
- Andriod build failed on macOS with arm64
- Application Error in Release Mode on Windows HOT 7
- [ ISSUE ] - Problem getting monitor brightness WINDOWS HOT 5
- GStreamer integration
- I am getting this error when trying to build on linux using flutter. I installed flutter using snapd. HOT 1
- Hls Quality switching option?
- Seek has severe delay on release version of iOS
- Support windows arm 64 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from media-kit.