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)
- Add a way to receive one-time controller callbacks
- No audio on second track HOT 4
- Not work properly on Android 14 and 15 HOT 1
- 2 major issues, what song is playing and background video/audio play HOT 1
- 在iphone上,调用screenshot截图,视频是竖向的,但是截图是横向的
- Do not want to request permission HOT 1
- Subtitle sync
- Remove references to deprecated v1 Android embedding HOT 2
- Linux Build Failed on ubuntu 24.04 links to target "PkgConfig::mpv" but the target was not found. HOT 1
- [Question] Is Media-Kit support picture in picture ?
- Feature request: image streams
- [media_kit v1.1.10] play/pause state bug when de-queueing while paused HOT 5
- Feature request: errorBuilder
- how to set loop play
- Packae doesn't compile on Fedora 40
- Crash on android when playing .mpd video
- How to play H264 raw stream? HOT 1
- How to enable full-xxx.jar HOT 2
- Error when reproduce a video The 'com.alexmercerind/media_kit_video' channel sent a message from native to Flutter on a non-platform thread
- media_kit: arm64-v8a JAR verification failed - BUG
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.