更改播放器为media_kit

This commit is contained in:
rang 2025-12-06 17:50:37 +08:00
parent 1a317308dd
commit ac6158123f
14 changed files with 1092 additions and 878 deletions

View file

@ -1,10 +1,48 @@
import 'package:audio_service/audio_service.dart';
import 'package:just_audio/just_audio.dart';
import 'package:media_kit/media_kit.dart';
class AbsAudioHandler extends BaseAudioHandler with QueueHandler, SeekHandler {
final AudioPlayer player;
final Player player = Player();
AbsAudioHandler(this.player);
AbsAudioHandler() {
// 1. /
player.stream.playing.listen((bool playing) {
playbackState.add(playbackState.value.copyWith(
playing: playing,
// playing processingState
processingState:
playing ? AudioProcessingState.ready : AudioProcessingState.idle,
));
});
// 2.
player.stream.position.listen((Duration position) {
playbackState.add(playbackState.value.copyWith(
updatePosition: position,
));
});
// 3.
player.stream.duration.listen((Duration? duration) {
// mediaItem duration
final currentItem = mediaItem.value;
if (currentItem != null && duration != null) {
mediaItem.add(currentItem.copyWith(duration: duration));
}
});
player.stream.completed.listen((bool playing) {
print('播放完成');
});
}
Future<void> playOrPause() async {
await player.playOrPause();
}
Future<void> setMediaItem(MediaItem mediaItem) async {
this.mediaItem.add(mediaItem);
await player.open(Media(mediaItem.id), play: false);
// ignore: unnecessary_null_comparison
await player.stream.duration.firstWhere((d) => d != null);
}
//
@override
@ -19,12 +57,12 @@ class AbsAudioHandler extends BaseAudioHandler with QueueHandler, SeekHandler {
@override
Future<void> skipToNext() async {
await player.seekToNext();
await player.next();
}
@override
Future<void> skipToPrevious() async {
await player.seekToPrevious();
await player.previous();
}
@override
@ -34,6 +72,10 @@ class AbsAudioHandler extends BaseAudioHandler with QueueHandler, SeekHandler {
@override
Future<void> setSpeed(double speed) async {
await player.setSpeed(speed);
await player.setRate(speed);
}
Future<void> setVolume(double volume) async {
await player.setVolume(volume);
}
}

View file

@ -1,5 +1,29 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'package:just_audio/just_audio.dart';
import 'package:shelfsdk/audiobookshelf_api.dart';
// import 'package:just_audio/just_audio.dart';
import 'package:shelfsdk/audiobookshelf_api.dart' as api;
class AbsAudioPlayer extends AudioPlayer {}
class AbsPlayerState {
api.BookExpanded? book;
//
final api.BookChapter? currentChapter;
//
final int currentIndex;
AbsPlayerState({
this.book,
this.currentChapter,
this.currentIndex = 0,
});
AbsPlayerState copyWith({
api.BookExpanded? book,
api.BookChapter? currentChapter,
int? currentIndex,
}) {
return AbsPlayerState(
book: book ?? this.book,
currentChapter: currentChapter ?? this.currentChapter,
currentIndex: currentIndex ?? this.currentIndex,
);
}
}

View file

@ -0,0 +1,30 @@
import 'package:audio_service/audio_service.dart';
import 'package:audio_session/audio_session.dart';
import 'package:media_kit/media_kit.dart';
import 'package:vaani/features/player/core/abs_audio_handler.dart' as core;
Future<core.AbsAudioHandler> absAudioHandlerInit() async {
// for playing audio on windows, linux
MediaKit.ensureInitialized();
// for configuring how this app will interact with other audio apps
final session = await AudioSession.instance;
await session.configure(const AudioSessionConfiguration.speech());
final audioService = await AudioService.init(
builder: () => core.AbsAudioHandler(),
config: const AudioServiceConfig(
androidNotificationChannelId: 'dr.blank.vaani.channel.audio',
androidNotificationChannelName: 'ABSPlayback',
androidNotificationChannelDescription:
'Needed to control audio from lock screen',
androidNotificationOngoing: false,
androidStopForegroundOnPause: false,
androidNotificationIcon: 'drawable/ic_stat_logo',
preloadArtwork: true,
// fastForwardInterval: Duration(seconds: 20),
// rewindInterval: Duration(seconds: 20),
),
);
return audioService;
}

View file

@ -1,30 +1,36 @@
import 'package:audio_service/audio_service.dart';
import 'package:audio_session/audio_session.dart';
import 'package:collection/collection.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:just_audio_media_kit/just_audio_media_kit.dart';
import 'package:logging/logging.dart';
import 'package:media_kit/media_kit.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:shelfsdk/audiobookshelf_api.dart';
import 'package:shelfsdk/audiobookshelf_api.dart' as api;
import 'package:vaani/api/api_provider.dart';
import 'package:vaani/api/library_item_provider.dart';
import 'package:vaani/features/downloads/providers/download_manager.dart';
import 'package:vaani/features/per_book_settings/providers/book_settings_provider.dart';
import 'package:vaani/features/player/core/abs_audio_handler.dart' as core;
import 'package:vaani/features/player/core/abs_audio_player.dart' as core;
import 'package:vaani/features/player/core/audiobook_player.dart';
import 'package:vaani/features/settings/app_settings_provider.dart';
import 'package:vaani/globals.dart';
import 'package:vaani/shared/extensions/chapter.dart';
part 'abs_provider.g.dart';
final _logger = Logger('AbsPlayerProvider');
@Riverpod(keepAlive: true)
Future<core.AbsAudioHandler> absAudioHandler(Ref ref) async {
Future<core.AbsAudioHandler> absAudioHandlerInit(Ref ref) async {
// for playing audio on windows, linux
JustAudioMediaKit.ensureInitialized();
MediaKit.ensureInitialized();
// for configuring how this app will interact with other audio apps
final session = await AudioSession.instance;
await session.configure(const AudioSessionConfiguration.speech());
final player = ref.read(absAudioPlayerProvider);
final audioService = await AudioService.init(
builder: () => core.AbsAudioHandler(player),
builder: () => core.AbsAudioHandler(),
config: const AudioServiceConfig(
androidNotificationChannelId: 'dr.blank.vaani.channel.audio',
androidNotificationChannelName: 'ABSPlayback',
@ -39,18 +45,130 @@ Future<core.AbsAudioHandler> absAudioHandler(Ref ref) async {
),
);
_logger.finer('created simple player');
return audioService;
}
@Riverpod(keepAlive: true)
class AbsAudioPlayer extends _$AbsAudioPlayer {
class AbsPlayer extends _$AbsPlayer {
@override
core.AbsAudioPlayer build() {
final player = core.AbsAudioPlayer();
ref.onDispose(player.dispose);
_logger.finer('created simple player');
return player;
core.AbsAudioHandler build() {
return ref.read(absAudioHandlerInitProvider).valueOrNull!;
}
}
@Riverpod(keepAlive: true)
class AbsState extends _$AbsState {
@override
core.AbsPlayerState build() {
return core.AbsPlayerState();
}
//
Future<void> load(api.BookExpanded book, Duration? currentTime) async {
final player = ref.read(absPlayerProvider);
if (state.book == book || state.book?.libraryItemId == book.libraryItemId) {
appLogger.info('Book was already set');
player.playOrPause();
return;
}
final appSettings = ref.read(appSettingsProvider);
final api = ref.read(authenticatedApiProvider);
final downloadManager = ref.read(simpleDownloadManagerProvider);
final libItem =
await ref.read(libraryItemProvider(book.libraryItemId).future);
final downloadedUris = await downloadManager.getDownloadedFilesUri(libItem);
var bookPlayerSettings =
ref.read(bookSettingsProvider(book.libraryItemId)).playerSettings;
var appPlayerSettings = ref.read(appSettingsProvider).playerSettings;
var configurePlayerForEveryBook =
appPlayerSettings.configurePlayerForEveryBook;
final trackToPlay = book.findTrackAtTime(currentTime ?? Duration.zero);
final chapterToPlay = book.findChapterAtTime(currentTime ?? Duration.zero);
final initialIndex = book.tracks.indexOf(trackToPlay);
final initialPositionInTrack =
currentTime != null ? currentTime - trackToPlay.startOffset : null;
final title = appSettings.notificationSettings.primaryTitle
.formatNotificationTitle(book);
final album = appSettings.notificationSettings.secondaryTitle
.formatNotificationTitle(book);
final id = _getUri(trackToPlay, downloadedUris,
baseUrl: api.baseUrl, token: api.token!)
.toString();
final item = MediaItem(
id: id,
title: title,
album: album,
displayTitle: title,
displaySubtitle: album,
duration: chapterToPlay.duration,
artUri: Uri.parse(
'${api.baseUrl}/api/items/${book.libraryItemId}/cover?token=${api.token!}',
),
);
state = state.copyWith(
book: book,
currentChapter: chapterToPlay,
currentIndex: initialIndex,
);
player.playMediaItem(item);
await Future.wait([
player.setMediaItem(item),
// player.setVolume(
// configurePlayerForEveryBook
// ? bookPlayerSettings.preferredDefaultVolume ??
// appPlayerSettings.preferredDefaultVolume
// : appPlayerSettings.preferredDefaultVolume,
// ),
player.setSpeed(
configurePlayerForEveryBook
? bookPlayerSettings.preferredDefaultSpeed ??
appPlayerSettings.preferredDefaultSpeed
: appPlayerSettings.preferredDefaultSpeed,
),
player.play(),
]);
// player.setSourceAudiobook(
// book,
// baseUrl: api.baseUrl,
// token: api.token!,
// initialPosition: currentTime,
// downloadedUris: downloadedUris,
// volume: configurePlayerForEveryBook
// ? bookPlayerSettings.preferredDefaultVolume ??
// appPlayerSettings.preferredDefaultVolume
// : appPlayerSettings.preferredDefaultVolume,
// speed: configurePlayerForEveryBook
// ? bookPlayerSettings.preferredDefaultSpeed ??
// appPlayerSettings.preferredDefaultSpeed
// : appPlayerSettings.preferredDefaultSpeed,
// );
}
Future<void> next() async {}
Future<void> previous() async {}
Uri _getUri(
api.AudioTrack track,
List<Uri>? downloadedUris, {
required Uri baseUrl,
required String token,
}) {
// check if the track is in the downloadedUris
final uri = downloadedUris?.firstWhereOrNull(
(element) {
return element.pathSegments.last == track.metadata?.filename;
},
);
return uri ??
Uri.parse('${baseUrl.toString()}${track.contentUrl}?token=$token');
}
}

View file

@ -6,38 +6,54 @@ part of 'abs_provider.dart';
// RiverpodGenerator
// **************************************************************************
String _$absAudioHandlerHash() => r'f4ef20cc3e244d5d37354ef38a1e0fdbd89412f4';
String _$absAudioHandlerInitHash() =>
r'8815383b114e5e3da826afdea58bf0a884b1e3f2';
/// See also [absAudioHandler].
@ProviderFor(absAudioHandler)
final absAudioHandlerProvider = FutureProvider<core.AbsAudioHandler>.internal(
absAudioHandler,
name: r'absAudioHandlerProvider',
/// See also [absAudioHandlerInit].
@ProviderFor(absAudioHandlerInit)
final absAudioHandlerInitProvider =
FutureProvider<core.AbsAudioHandler>.internal(
absAudioHandlerInit,
name: r'absAudioHandlerInitProvider',
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
? null
: _$absAudioHandlerHash,
: _$absAudioHandlerInitHash,
dependencies: null,
allTransitiveDependencies: null,
);
@Deprecated('Will be removed in 3.0. Use Ref instead')
// ignore: unused_element
typedef AbsAudioHandlerRef = FutureProviderRef<core.AbsAudioHandler>;
String _$absAudioPlayerHash() => r'68a56d45a9f165d257c23f81d9bf7d0930425464';
typedef AbsAudioHandlerInitRef = FutureProviderRef<core.AbsAudioHandler>;
String _$absPlayerHash() => r'c313a2456bb221b83f3cd2142ae63d6463ef304b';
/// See also [AbsAudioPlayer].
@ProviderFor(AbsAudioPlayer)
final absAudioPlayerProvider =
NotifierProvider<AbsAudioPlayer, core.AbsAudioPlayer>.internal(
AbsAudioPlayer.new,
name: r'absAudioPlayerProvider',
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
? null
: _$absAudioPlayerHash,
/// See also [AbsPlayer].
@ProviderFor(AbsPlayer)
final absPlayerProvider =
NotifierProvider<AbsPlayer, core.AbsAudioHandler>.internal(
AbsPlayer.new,
name: r'absPlayerProvider',
debugGetCreateSourceHash:
const bool.fromEnvironment('dart.vm.product') ? null : _$absPlayerHash,
dependencies: null,
allTransitiveDependencies: null,
);
typedef _$AbsAudioPlayer = Notifier<core.AbsAudioPlayer>;
typedef _$AbsPlayer = Notifier<core.AbsAudioHandler>;
String _$absStateHash() => r'fb11d9d970e0de2dfd722c1f0de2a3b9b10f2859';
/// See also [AbsState].
@ProviderFor(AbsState)
final absStateProvider =
NotifierProvider<AbsState, core.AbsPlayerState>.internal(
AbsState.new,
name: r'absStateProvider',
debugGetCreateSourceHash:
const bool.fromEnvironment('dart.vm.product') ? null : _$absStateHash,
dependencies: null,
allTransitiveDependencies: null,
);
typedef _$AbsState = Notifier<core.AbsPlayerState>;
// ignore_for_file: type=lint
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package

View file

@ -1,6 +1,6 @@
import 'package:audio_service/audio_service.dart';
import 'package:audio_session/audio_session.dart';
import 'package:just_audio_media_kit/just_audio_media_kit.dart';
// import 'package:just_audio_media_kit/just_audio_media_kit.dart';
import 'package:riverpod/riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:vaani/features/player/core/audiobook_player.dart';
@ -10,7 +10,7 @@ part 'audiobook_player.g.dart';
@Riverpod(keepAlive: true)
Future<AbsAudioHandler> audioHandlerInit(Ref ref) async {
// for playing audio on windows, linux
JustAudioMediaKit.ensureInitialized();
// JustAudioMediaKit.ensureInitialized();
// for configuring how this app will interact with other audio apps
final session = await AudioSession.instance;

View file

@ -6,7 +6,7 @@ part of 'audiobook_player.dart';
// RiverpodGenerator
// **************************************************************************
String _$audioHandlerInitHash() => r'f4907b614d5698c1c8fe8e999edd5fde46bc29f2';
String _$audioHandlerInitHash() => r'80f9912c0a93b4bbfe7da3967966065e78f2f6c2';
/// See also [audioHandlerInit].
@ProviderFor(audioHandlerInit)

View file

@ -54,10 +54,8 @@ class MessageLookup extends MessageLookupByLibrary {
"accountDeleteServer": MessageLookupByLibrary.simpleMessage(
"Delete Server",
),
"accountInvalidURL":
MessageLookupByLibrary.simpleMessage("Invalid URL"),
"accountManage":
MessageLookupByLibrary.simpleMessage("Manage Accounts"),
"accountInvalidURL": MessageLookupByLibrary.simpleMessage("Invalid URL"),
"accountManage": MessageLookupByLibrary.simpleMessage("Manage Accounts"),
"accountRegisteredServers": MessageLookupByLibrary.simpleMessage(
"Registered Servers",
),
@ -96,8 +94,7 @@ class MessageLookup extends MessageLookupByLibrary {
"autoTurnOnTimerAlways": MessageLookupByLibrary.simpleMessage(
"Always Auto Turn On Timer",
),
"autoTurnOnTimerAlwaysDescription":
MessageLookupByLibrary.simpleMessage(
"autoTurnOnTimerAlwaysDescription": MessageLookupByLibrary.simpleMessage(
"Always turn on the sleep timer, no matter what",
),
"autoTurnOnTimerDescription": MessageLookupByLibrary.simpleMessage(
@ -125,11 +122,9 @@ class MessageLookup extends MessageLookupByLibrary {
"bookAuthors": MessageLookupByLibrary.simpleMessage("Authors"),
"bookDownloads": MessageLookupByLibrary.simpleMessage("Downloads"),
"bookGenres": MessageLookupByLibrary.simpleMessage("Genres"),
"bookMetadataAbridged":
MessageLookupByLibrary.simpleMessage("Abridged"),
"bookMetadataAbridged": MessageLookupByLibrary.simpleMessage("Abridged"),
"bookMetadataLength": MessageLookupByLibrary.simpleMessage("Length"),
"bookMetadataPublished":
MessageLookupByLibrary.simpleMessage("Published"),
"bookMetadataPublished": MessageLookupByLibrary.simpleMessage("Published"),
"bookMetadataUnabridged": MessageLookupByLibrary.simpleMessage(
"Unabridged",
),
@ -183,13 +178,11 @@ class MessageLookup extends MessageLookupByLibrary {
"homeBookContinueSeries": MessageLookupByLibrary.simpleMessage(
"Continue Series",
),
"homeBookContinueSeriesDescription":
MessageLookupByLibrary.simpleMessage(
"homeBookContinueSeriesDescription": MessageLookupByLibrary.simpleMessage(
"Show play button for books in continue series shelf",
),
"homeBookDiscover": MessageLookupByLibrary.simpleMessage("Discover"),
"homeBookListenAgain":
MessageLookupByLibrary.simpleMessage("Listen Again"),
"homeBookListenAgain": MessageLookupByLibrary.simpleMessage("Listen Again"),
"homeBookListenAgainDescription": MessageLookupByLibrary.simpleMessage(
"Show play button for all books in listen again shelf",
),
@ -199,8 +192,7 @@ class MessageLookup extends MessageLookupByLibrary {
"homeBookRecentlyAdded": MessageLookupByLibrary.simpleMessage(
"Recently Added",
),
"homeBookRecommended":
MessageLookupByLibrary.simpleMessage("Recommended"),
"homeBookRecommended": MessageLookupByLibrary.simpleMessage("Recommended"),
"homeContinueListening": MessageLookupByLibrary.simpleMessage(
"Continue Listening",
),
@ -273,8 +265,7 @@ class MessageLookup extends MessageLookupByLibrary {
"nmpSettingsMediaControls": MessageLookupByLibrary.simpleMessage(
"Media Controls",
),
"nmpSettingsMediaControlsDescription":
MessageLookupByLibrary.simpleMessage(
"nmpSettingsMediaControlsDescription": MessageLookupByLibrary.simpleMessage(
"Select the media controls to display",
),
"nmpSettingsSelectOne": MessageLookupByLibrary.simpleMessage(
@ -293,32 +284,27 @@ class MessageLookup extends MessageLookupByLibrary {
"nmpSettingsSubTitleDescription": MessageLookupByLibrary.simpleMessage(
"The subtitle of the notification\n",
),
"nmpSettingsTitle":
MessageLookupByLibrary.simpleMessage("Primary Title"),
"nmpSettingsTitle": MessageLookupByLibrary.simpleMessage("Primary Title"),
"nmpSettingsTitleDescription": MessageLookupByLibrary.simpleMessage(
"The title of the notification\n",
),
"no": MessageLookupByLibrary.simpleMessage("No"),
"notImplemented":
MessageLookupByLibrary.simpleMessage("Not implemented"),
"notImplemented": MessageLookupByLibrary.simpleMessage("Not implemented"),
"notificationMediaPlayer": MessageLookupByLibrary.simpleMessage(
"Notification Media Player",
),
"notificationMediaPlayerDescription":
MessageLookupByLibrary.simpleMessage(
"notificationMediaPlayerDescription": MessageLookupByLibrary.simpleMessage(
"Customize the media player in notifications",
),
"ok": MessageLookupByLibrary.simpleMessage("OK"),
"pause": MessageLookupByLibrary.simpleMessage("Pause"),
"play": MessageLookupByLibrary.simpleMessage("Play"),
"playerSettings":
MessageLookupByLibrary.simpleMessage("Player Settings"),
"playerSettings": MessageLookupByLibrary.simpleMessage("Player Settings"),
"playerSettingsCompleteTime": MessageLookupByLibrary.simpleMessage(
"Mark Complete When Time Left",
),
"playerSettingsCompleteTimeDescriptionHead":
MessageLookupByLibrary.simpleMessage(
"Mark complete when less than "),
MessageLookupByLibrary.simpleMessage("Mark complete when less than "),
"playerSettingsCompleteTimeDescriptionTail":
MessageLookupByLibrary.simpleMessage(" left in the book"),
"playerSettingsDescription": MessageLookupByLibrary.simpleMessage(
@ -333,8 +319,7 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage(
"Show the progress of the current chapter in the player",
),
"playerSettingsDisplayTotalProgress":
MessageLookupByLibrary.simpleMessage(
"playerSettingsDisplayTotalProgress": MessageLookupByLibrary.simpleMessage(
"Show Total Progress",
),
"playerSettingsDisplayTotalProgressDescription":
@ -363,8 +348,7 @@ class MessageLookup extends MessageLookupByLibrary {
),
"playerSettingsPlaybackReportingMinimumDescriptionTail":
MessageLookupByLibrary.simpleMessage("of the book"),
"playerSettingsRememberForEveryBook":
MessageLookupByLibrary.simpleMessage(
"playerSettingsRememberForEveryBook": MessageLookupByLibrary.simpleMessage(
"Remember Player Settings for Every Book",
),
"playerSettingsRememberForEveryBookDescription":
@ -378,17 +362,14 @@ class MessageLookup extends MessageLookupByLibrary {
"playerSettingsSpeedOptions": MessageLookupByLibrary.simpleMessage(
"Speed Options",
),
"playerSettingsSpeedOptionsSelect":
MessageLookupByLibrary.simpleMessage(
"playerSettingsSpeedOptionsSelect": MessageLookupByLibrary.simpleMessage(
"Select Speed Options",
),
"playerSettingsSpeedOptionsSelectAdd":
MessageLookupByLibrary.simpleMessage(
"playerSettingsSpeedOptionsSelectAdd": MessageLookupByLibrary.simpleMessage(
"Add Speed Option",
),
"playerSettingsSpeedOptionsSelectAddHelper":
MessageLookupByLibrary.simpleMessage(
"Enter a new speed option to add"),
MessageLookupByLibrary.simpleMessage("Enter a new speed option to add"),
"playerSettingsSpeedSelect": MessageLookupByLibrary.simpleMessage(
"Select Speed",
),
@ -436,8 +417,7 @@ class MessageLookup extends MessageLookupByLibrary {
"shakeActivationThreshold": MessageLookupByLibrary.simpleMessage(
"Shake Activation Threshold",
),
"shakeActivationThresholdDescription":
MessageLookupByLibrary.simpleMessage(
"shakeActivationThresholdDescription": MessageLookupByLibrary.simpleMessage(
"The higher the threshold, the harder you need to shake",
),
"shakeDetector": MessageLookupByLibrary.simpleMessage("Shake Detector"),
@ -475,8 +455,7 @@ class MessageLookup extends MessageLookupByLibrary {
"themeModeHighContrast": MessageLookupByLibrary.simpleMessage(
"High Contrast Mode",
),
"themeModeHighContrastDescription":
MessageLookupByLibrary.simpleMessage(
"themeModeHighContrastDescription": MessageLookupByLibrary.simpleMessage(
"Increase the contrast between the background and the text",
),
"themeModeLight": MessageLookupByLibrary.simpleMessage("Light"),
@ -491,8 +470,7 @@ class MessageLookup extends MessageLookupByLibrary {
"themeSettingsColorsBook": MessageLookupByLibrary.simpleMessage(
"Adaptive Theme on Item Page",
),
"themeSettingsColorsBookDescription":
MessageLookupByLibrary.simpleMessage(
"themeSettingsColorsBookDescription": MessageLookupByLibrary.simpleMessage(
"Get fancy with the colors on the item page at the cost of some performance",
),
"themeSettingsColorsCurrent": MessageLookupByLibrary.simpleMessage(

View file

@ -50,8 +50,7 @@ class MessageLookup extends MessageLookupByLibrary {
"accountDeleteServer": MessageLookupByLibrary.simpleMessage("删除服务器"),
"accountInvalidURL": MessageLookupByLibrary.simpleMessage("无效网址"),
"accountManage": MessageLookupByLibrary.simpleMessage("帐户管理"),
"accountRegisteredServers":
MessageLookupByLibrary.simpleMessage("已注册服务器"),
"accountRegisteredServers": MessageLookupByLibrary.simpleMessage("已注册服务器"),
"accountRemoveServerAndUsers": MessageLookupByLibrary.simpleMessage(
"删除服务器和用户",
),
@ -61,8 +60,7 @@ class MessageLookup extends MessageLookupByLibrary {
"accountRemoveServerAndUsersTail": MessageLookupByLibrary.simpleMessage(
" 以及该应用程序中所有用户的登录信息。",
),
"accountRemoveUserLogin":
MessageLookupByLibrary.simpleMessage("删除用户登录"),
"accountRemoveUserLogin": MessageLookupByLibrary.simpleMessage("删除用户登录"),
"accountRemoveUserLoginHead": MessageLookupByLibrary.simpleMessage(
"这将删除用户 ",
),
@ -74,15 +72,11 @@ class MessageLookup extends MessageLookupByLibrary {
"accountUsersCount": m1,
"appSettings": MessageLookupByLibrary.simpleMessage("应用设置"),
"appearance": MessageLookupByLibrary.simpleMessage("外观"),
"autoSleepTimerSettings":
MessageLookupByLibrary.simpleMessage("自动睡眠定时器设置"),
"autoTurnOnSleepTimer":
MessageLookupByLibrary.simpleMessage("自动开启睡眠定时器"),
"autoSleepTimerSettings": MessageLookupByLibrary.simpleMessage("自动睡眠定时器设置"),
"autoTurnOnSleepTimer": MessageLookupByLibrary.simpleMessage("自动开启睡眠定时器"),
"autoTurnOnTimer": MessageLookupByLibrary.simpleMessage("自动开启定时器"),
"autoTurnOnTimerAlways":
MessageLookupByLibrary.simpleMessage("始终自动开启定时器"),
"autoTurnOnTimerAlwaysDescription":
MessageLookupByLibrary.simpleMessage(
"autoTurnOnTimerAlways": MessageLookupByLibrary.simpleMessage("始终自动开启定时器"),
"autoTurnOnTimerAlwaysDescription": MessageLookupByLibrary.simpleMessage(
"总是打开睡眠定时器",
),
"autoTurnOnTimerDescription": MessageLookupByLibrary.simpleMessage(
@ -124,8 +118,7 @@ class MessageLookup extends MessageLookupByLibrary {
"copyToClipboardDescription": MessageLookupByLibrary.simpleMessage(
"将应用程序设置复制到剪贴板",
),
"copyToClipboardToast":
MessageLookupByLibrary.simpleMessage("设置已复制到剪贴板"),
"copyToClipboardToast": MessageLookupByLibrary.simpleMessage("设置已复制到剪贴板"),
"delete": MessageLookupByLibrary.simpleMessage("删除"),
"deleteDialog": m2,
"deleted": m3,
@ -135,13 +128,11 @@ class MessageLookup extends MessageLookupByLibrary {
"general": MessageLookupByLibrary.simpleMessage("通用"),
"help": MessageLookupByLibrary.simpleMessage("Help"),
"home": MessageLookupByLibrary.simpleMessage("首页"),
"homeBookContinueListening":
MessageLookupByLibrary.simpleMessage("继续收听"),
"homeBookContinueListening": MessageLookupByLibrary.simpleMessage("继续收听"),
"homeBookContinueListeningDescription":
MessageLookupByLibrary.simpleMessage("继续收听书架上显示播放按钮"),
"homeBookContinueSeries": MessageLookupByLibrary.simpleMessage("继续系列"),
"homeBookContinueSeriesDescription":
MessageLookupByLibrary.simpleMessage(
"homeBookContinueSeriesDescription": MessageLookupByLibrary.simpleMessage(
"继续系列书架上显示播放按钮",
),
"homeBookDiscover": MessageLookupByLibrary.simpleMessage("发现"),
@ -163,8 +154,7 @@ class MessageLookup extends MessageLookupByLibrary {
),
"homePageSettingsOtherShelvesDescription":
MessageLookupByLibrary.simpleMessage("显示所有剩余书架上所有书籍的播放按钮"),
"homePageSettingsQuickPlay":
MessageLookupByLibrary.simpleMessage("继续播放"),
"homePageSettingsQuickPlay": MessageLookupByLibrary.simpleMessage("继续播放"),
"homeStartListening": MessageLookupByLibrary.simpleMessage("开始收听"),
"language": MessageLookupByLibrary.simpleMessage("语言"),
"languageDescription": MessageLookupByLibrary.simpleMessage("语言切换"),
@ -181,8 +171,7 @@ class MessageLookup extends MessageLookupByLibrary {
"loginOpenID": MessageLookupByLibrary.simpleMessage("OpenID"),
"loginPassword": MessageLookupByLibrary.simpleMessage("密码"),
"loginServerClick": MessageLookupByLibrary.simpleMessage("单击此处"),
"loginServerConnected":
MessageLookupByLibrary.simpleMessage("服务器已连接,请登录"),
"loginServerConnected": MessageLookupByLibrary.simpleMessage("服务器已连接,请登录"),
"loginServerNo": MessageLookupByLibrary.simpleMessage("没有服务器? "),
"loginServerNoConnected": MessageLookupByLibrary.simpleMessage(
"请输入您的AudiobookShelf服务器的URL",
@ -195,10 +184,8 @@ class MessageLookup extends MessageLookupByLibrary {
"logs": MessageLookupByLibrary.simpleMessage("日志"),
"nmpSettingsBackward": MessageLookupByLibrary.simpleMessage("快退间隔"),
"nmpSettingsForward": MessageLookupByLibrary.simpleMessage("快进间隔"),
"nmpSettingsMediaControls":
MessageLookupByLibrary.simpleMessage("媒体控制"),
"nmpSettingsMediaControlsDescription":
MessageLookupByLibrary.simpleMessage(
"nmpSettingsMediaControls": MessageLookupByLibrary.simpleMessage("媒体控制"),
"nmpSettingsMediaControlsDescription": MessageLookupByLibrary.simpleMessage(
"选择要显示的媒体控件",
),
"nmpSettingsSelectOne": MessageLookupByLibrary.simpleMessage(
@ -219,10 +206,8 @@ class MessageLookup extends MessageLookupByLibrary {
),
"no": MessageLookupByLibrary.simpleMessage(""),
"notImplemented": MessageLookupByLibrary.simpleMessage("未实现"),
"notificationMediaPlayer":
MessageLookupByLibrary.simpleMessage("通知媒体播放器"),
"notificationMediaPlayerDescription":
MessageLookupByLibrary.simpleMessage(
"notificationMediaPlayer": MessageLookupByLibrary.simpleMessage("通知媒体播放器"),
"notificationMediaPlayerDescription": MessageLookupByLibrary.simpleMessage(
"在通知中自定义媒体播放器",
),
"ok": MessageLookupByLibrary.simpleMessage("确定"),
@ -244,8 +229,7 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("显示章节进度"),
"playerSettingsDisplayChapterProgressDescription":
MessageLookupByLibrary.simpleMessage("在播放器中显示当前章节的进度"),
"playerSettingsDisplayTotalProgress":
MessageLookupByLibrary.simpleMessage(
"playerSettingsDisplayTotalProgress": MessageLookupByLibrary.simpleMessage(
"显示总进度",
),
"playerSettingsDisplayTotalProgressDescription":
@ -268,8 +252,7 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("不要报告本书前 "),
"playerSettingsPlaybackReportingMinimumDescriptionTail":
MessageLookupByLibrary.simpleMessage(" 的播放"),
"playerSettingsRememberForEveryBook":
MessageLookupByLibrary.simpleMessage(
"playerSettingsRememberForEveryBook": MessageLookupByLibrary.simpleMessage(
"记住每本书的播放器设置",
),
"playerSettingsRememberForEveryBookDescription":
@ -281,18 +264,15 @@ class MessageLookup extends MessageLookupByLibrary {
"playerSettingsSpeedOptions": MessageLookupByLibrary.simpleMessage(
"播放速度选项",
),
"playerSettingsSpeedOptionsSelect":
MessageLookupByLibrary.simpleMessage(
"playerSettingsSpeedOptionsSelect": MessageLookupByLibrary.simpleMessage(
"播放速度选项",
),
"playerSettingsSpeedOptionsSelectAdd":
MessageLookupByLibrary.simpleMessage(
"playerSettingsSpeedOptionsSelectAdd": MessageLookupByLibrary.simpleMessage(
"添加一个速度选项",
),
"playerSettingsSpeedOptionsSelectAddHelper":
MessageLookupByLibrary.simpleMessage("输入一个新的速度选项"),
"playerSettingsSpeedSelect":
MessageLookupByLibrary.simpleMessage("选择播放速度"),
"playerSettingsSpeedSelect": MessageLookupByLibrary.simpleMessage("选择播放速度"),
"playerSettingsSpeedSelectHelper": MessageLookupByLibrary.simpleMessage(
"输入默认的播放速度",
),
@ -313,10 +293,8 @@ class MessageLookup extends MessageLookupByLibrary {
"restoreBackupHint": MessageLookupByLibrary.simpleMessage("将备份粘贴到此处"),
"restoreBackupInvalid": MessageLookupByLibrary.simpleMessage("无效备份"),
"restoreBackupSuccess": MessageLookupByLibrary.simpleMessage("设置已恢复"),
"restoreBackupValidator":
MessageLookupByLibrary.simpleMessage("请将备份粘贴到此处"),
"restoreDescription":
MessageLookupByLibrary.simpleMessage("从备份中还原应用程序设置"),
"restoreBackupValidator": MessageLookupByLibrary.simpleMessage("请将备份粘贴到此处"),
"restoreDescription": MessageLookupByLibrary.simpleMessage("从备份中还原应用程序设置"),
"resume": MessageLookupByLibrary.simpleMessage("继续"),
"retry": MessageLookupByLibrary.simpleMessage("重试"),
"settings": MessageLookupByLibrary.simpleMessage("设置"),
@ -324,10 +302,8 @@ class MessageLookup extends MessageLookupByLibrary {
"shakeActionDescription": MessageLookupByLibrary.simpleMessage(
"检测到抖动时要执行的操作",
),
"shakeActivationThreshold":
MessageLookupByLibrary.simpleMessage("抖动激活阈值"),
"shakeActivationThresholdDescription":
MessageLookupByLibrary.simpleMessage(
"shakeActivationThreshold": MessageLookupByLibrary.simpleMessage("抖动激活阈值"),
"shakeActivationThresholdDescription": MessageLookupByLibrary.simpleMessage(
"门槛越高,你就越难摇晃",
),
"shakeDetector": MessageLookupByLibrary.simpleMessage("抖动检测器"),
@ -338,8 +314,7 @@ class MessageLookup extends MessageLookupByLibrary {
"shakeDetectorEnableDescription": MessageLookupByLibrary.simpleMessage(
"启用抖动检测以执行各种操作",
),
"shakeDetectorSettings":
MessageLookupByLibrary.simpleMessage("抖动检测器设置"),
"shakeDetectorSettings": MessageLookupByLibrary.simpleMessage("抖动检测器设置"),
"shakeFeedback": MessageLookupByLibrary.simpleMessage("抖动反馈"),
"shakeFeedbackDescription": MessageLookupByLibrary.simpleMessage(
"检测到抖动时给出的反馈",
@ -354,21 +329,18 @@ class MessageLookup extends MessageLookupByLibrary {
"themeMode": MessageLookupByLibrary.simpleMessage("主题模式"),
"themeModeDark": MessageLookupByLibrary.simpleMessage("深色"),
"themeModeHighContrast": MessageLookupByLibrary.simpleMessage("高对比度模式"),
"themeModeHighContrastDescription":
MessageLookupByLibrary.simpleMessage(
"themeModeHighContrastDescription": MessageLookupByLibrary.simpleMessage(
"增加背景和文本之间的对比度",
),
"themeModeLight": MessageLookupByLibrary.simpleMessage("浅色"),
"themeModeSystem": MessageLookupByLibrary.simpleMessage("跟随系统"),
"themeSettings": MessageLookupByLibrary.simpleMessage("主题设置"),
"themeSettingsColors": MessageLookupByLibrary.simpleMessage("主题色"),
"themeSettingsColorsAndroid":
MessageLookupByLibrary.simpleMessage("主题色"),
"themeSettingsColorsAndroid": MessageLookupByLibrary.simpleMessage("主题色"),
"themeSettingsColorsBook": MessageLookupByLibrary.simpleMessage(
"书籍详情页自适应主题",
),
"themeSettingsColorsBookDescription":
MessageLookupByLibrary.simpleMessage(
"themeSettingsColorsBookDescription": MessageLookupByLibrary.simpleMessage(
"以牺牲一些性能为代价,对书籍详情页的颜色进行美化",
),
"themeSettingsColorsCurrent": MessageLookupByLibrary.simpleMessage(
@ -379,8 +351,7 @@ class MessageLookup extends MessageLookupByLibrary {
"themeSettingsColorsDescription": MessageLookupByLibrary.simpleMessage(
"使用应用程序的系统主题色",
),
"themeSettingsDescription":
MessageLookupByLibrary.simpleMessage("自定义应用主题"),
"themeSettingsDescription": MessageLookupByLibrary.simpleMessage("自定义应用主题"),
"timeSecond": m7,
"unknown": MessageLookupByLibrary.simpleMessage("未知"),
"webVersion": MessageLookupByLibrary.simpleMessage("Web版本"),

View file

@ -8,7 +8,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:vaani/api/server_provider.dart';
import 'package:vaani/db/storage.dart';
import 'package:vaani/features/logging/core/logger.dart';
import 'package:vaani/features/player/providers/audiobook_player.dart';
import 'package:vaani/features/player/providers/abs_provider.dart';
import 'package:vaani/features/player/providers/currently_playing_provider.dart';
import 'package:vaani/features/settings/api_settings_provider.dart';
import 'package:vaani/features/settings/app_settings_provider.dart';
@ -38,7 +38,8 @@ void main() async {
// initialize audio player
// await configurePlayer();
await container.read(audioHandlerInitProvider.future);
// await container.read(audioHandlerInitProvider.future);
await container.read(absAudioHandlerInitProvider.future);
// run the app
runApp(
UncontrolledProviderScope(

View file

@ -11,6 +11,7 @@ import 'package:vaani/api/image_provider.dart';
import 'package:vaani/api/library_item_provider.dart' show libraryItemProvider;
import 'package:vaani/constants/hero_tag_conventions.dart';
import 'package:vaani/features/item_viewer/view/library_item_actions.dart';
import 'package:vaani/features/player/providers/abs_provider.dart';
import 'package:vaani/features/player/providers/currently_playing_provider.dart';
import 'package:vaani/features/player/providers/player_status_provider.dart';
import 'package:vaani/features/player/providers/audiobook_player.dart';
@ -295,7 +296,11 @@ class _BookOnShelfPlayButton extends HookConsumerWidget {
final book =
await ref.watch(libraryItemProvider(libraryItemId).future);
ref.read(currentBookProvider.notifier).update(
// ref.read(currentBookProvider.notifier).update(
// book.media.asBookExpanded,
// userProgress?.currentTime,
// );
ref.read(absStateProvider.notifier).load(
book.media.asBookExpanded,
userProgress?.currentTime,
);

View file

@ -12,6 +12,7 @@ import dynamic_color
import file_picker
import isar_flutter_libs
import just_audio
import media_kit_libs_macos_audio
import package_info_plus
import path_provider_foundation
import screen_retriever_macos
@ -29,6 +30,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FilePickerPlugin.register(with: registry.registrar(forPlugin: "FilePickerPlugin"))
IsarFlutterLibsPlugin.register(with: registry.registrar(forPlugin: "IsarFlutterLibsPlugin"))
JustAudioPlugin.register(with: registry.registrar(forPlugin: "JustAudioPlugin"))
MediaKitLibsMacosAudioPlugin.register(with: registry.registrar(forPlugin: "MediaKitLibsMacosAudioPlugin"))
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
ScreenRetrieverMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverMacosPlugin"))

View file

@ -95,7 +95,7 @@ packages:
source: hosted
version: "0.1.4"
audio_session:
dependency: "direct main"
dependency: transitive
description:
name: audio_session
sha256: "2b7fff16a552486d078bfc09a8cde19f426dc6d6329262b684182597bec5b1ac"
@ -786,14 +786,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.10.5"
just_audio_media_kit:
dependency: "direct main"
description:
name: just_audio_media_kit
sha256: f3cf04c3a50339709e87e90b4e841eef4364ab4be2bdbac0c54cc48679f84d23
url: "https://pub.dev"
source: hosted
version: "2.1.0"
just_audio_platform_interface:
dependency: transitive
description:
@ -907,23 +899,55 @@ packages:
source: hosted
version: "0.11.1"
media_kit:
dependency: transitive
dependency: "direct main"
description:
name: media_kit
sha256: dfd5ab85d49a1806b1314a0b81f3d14da48f0db0a657336b2d77c5f17db28944
sha256: "2a207ea7baf1a2ea2ff2016d512e572ca6fc02a937769effb5c27b4d682b4a53"
url: "https://pub.dev"
source: hosted
version: "1.2.2"
media_kit_libs_linux:
version: "1.2.3"
media_kit_libs_android_audio:
dependency: transitive
description:
name: media_kit_libs_android_audio
sha256: "8f8f9759e537e12d66f08bc4d5279eb1bb21a0ccc519ff3442c68a9f3b6dd68b"
url: "https://pub.dev"
source: hosted
version: "1.3.8"
media_kit_libs_audio:
dependency: "direct main"
description:
name: media_kit_libs_audio
sha256: "81bf506c234e81e3ec536ba72f8f700a928543c14c345220210cae0411636316"
url: "https://pub.dev"
source: hosted
version: "1.0.7"
media_kit_libs_ios_audio:
dependency: transitive
description:
name: media_kit_libs_ios_audio
sha256: "78ccf04e27d6b4ba00a355578ccb39b772f00d48269a6ac3db076edf2d51934f"
url: "https://pub.dev"
source: hosted
version: "1.1.4"
media_kit_libs_linux:
dependency: transitive
description:
name: media_kit_libs_linux
sha256: "2b473399a49ec94452c4d4ae51cfc0f6585074398d74216092bf3d54aac37ecf"
url: "https://pub.dev"
source: hosted
version: "1.2.1"
media_kit_libs_macos_audio:
dependency: transitive
description:
name: media_kit_libs_macos_audio
sha256: "3be21844df98f286de32808592835073cdef2c1a10078bac135da790badca950"
url: "https://pub.dev"
source: hosted
version: "1.1.4"
media_kit_libs_windows_audio:
dependency: "direct main"
dependency: transitive
description:
name: media_kit_libs_windows_audio
sha256: c2fd558cc87b9d89a801141fcdffe02e338a3b21a41a18fbd63d5b221a1b8e53

View file

@ -34,8 +34,6 @@ dependencies:
animated_list_plus: ^0.5.2
animated_theme_switcher: ^2.0.10
archive: ^4.0.5
audio_service: ^0.18.15
audio_session: ^0.1.23
audio_video_progress_bar: ^2.0.2
auto_scroll_text: ^0.0.7
background_downloader: ^9.2.0
@ -72,9 +70,14 @@ dependencies:
# ref: media-notification-config
# path: just_audio_background
# just_audio_windows: ^0.2.2
just_audio_media_kit: ^2.0.4
media_kit_libs_linux: any
media_kit_libs_windows_audio: any
# just_audio_media_kit: ^2.0.4
# media_kit_libs_linux: any
# media_kit_libs_windows_audio: any
audio_service: ^0.18.15
# audio_session: ^0.1.23
media_kit: ^1.2.3 # Primary package.
media_kit_libs_audio: any # Native audio dependencies.
list_wheel_scroll_view_nls: ^0.0.3
logging: ^1.2.0
logging_appenders: ^1.3.1