mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-07 21:48:14 -08:00
feat: Android TV support (#503)
Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
This commit is contained in:
parent
7ab8c015b9
commit
c299492d6d
168 changed files with 12019 additions and 3073 deletions
|
|
@ -1,5 +1,7 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import 'package:fladder/models/media_playback_model.dart';
|
||||
|
|
@ -77,6 +79,8 @@ class VideoPlayerNotifier extends StateNotifier<MediaControlsWrapper> {
|
|||
mediaState.update(
|
||||
(state) => state.playing == event ? state : state.copyWith(playing: event),
|
||||
);
|
||||
final currentState = playbackState;
|
||||
ref.read(playBackModel)?.updatePlaybackPosition(currentState.position, playbackState.playing, ref);
|
||||
}
|
||||
|
||||
Future<void> updatePosition(Duration event) async {
|
||||
|
|
@ -105,7 +109,7 @@ class VideoPlayerNotifier extends StateNotifier<MediaControlsWrapper> {
|
|||
}
|
||||
}
|
||||
|
||||
Future<bool> loadPlaybackItem(PlaybackModel model, {Duration? startPosition}) async {
|
||||
Future<bool> loadPlaybackItem(PlaybackModel model, Duration startPosition) async {
|
||||
await state.stop();
|
||||
mediaState
|
||||
.update((state) => state.copyWith(state: VideoPlayerState.fullScreen, buffering: true, errorPlaying: false));
|
||||
|
|
@ -114,13 +118,13 @@ class VideoPlayerNotifier extends StateNotifier<MediaControlsWrapper> {
|
|||
PlaybackModel? newPlaybackModel = model;
|
||||
|
||||
if (media != null) {
|
||||
await state.open(media.url, false);
|
||||
await state.loadVideo(model, startPosition, false);
|
||||
await state.setVolume(ref.read(videoPlayerSettingsProvider).volume);
|
||||
state.stateStream?.takeWhile((event) => event.buffering == true).listen(
|
||||
null,
|
||||
onDone: () async {
|
||||
final start = startPosition ?? await model.startDuration();
|
||||
if (start != null) {
|
||||
final start = startPosition;
|
||||
if (start != Duration.zero) {
|
||||
await state.seek(start);
|
||||
}
|
||||
await state.setAudioTrack(null, model);
|
||||
|
|
@ -138,4 +142,6 @@ class VideoPlayerNotifier extends StateNotifier<MediaControlsWrapper> {
|
|||
mediaState.update((state) => state.copyWith(errorPlaying: true));
|
||||
return false;
|
||||
}
|
||||
|
||||
Future<void> openPlayer(BuildContext context) async => state.openPlayer(context);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue