pre-migration to media_kit
This commit is contained in:
parent
950969b774
commit
ce7612883d
|
|
@ -167,7 +167,7 @@ class DeezerAudioSource extends StreamAudioSource {
|
|||
// encrypt with AES ECB
|
||||
final k = Uint8List.fromList('jo6aey6haid2Teih'.codeUnits);
|
||||
final encrypter = Encrypter(AES(Key(k), mode: AESMode.ecb, padding: null));
|
||||
final step3 = encrypter
|
||||
final String step3 = encrypter
|
||||
.encryptBytes(step2, iv: IV(Uint8List(8)))
|
||||
.base16
|
||||
.toLowerCase();
|
||||
|
|
@ -212,7 +212,13 @@ class DeezerAudioSource extends StreamAudioSource {
|
|||
}
|
||||
|
||||
late final StreamController<List<int>> controller;
|
||||
final uri = await _fallbackUrl();
|
||||
|
||||
final Uri uri;
|
||||
try {
|
||||
uri = await _fallbackUrl();
|
||||
} on QualityException {
|
||||
rethrow;
|
||||
}
|
||||
_logger.fine("Downloading track from ${uri.toString()}");
|
||||
final int deezerStart = start - (start % 2048);
|
||||
final req = http.Request('GET', uri)
|
||||
|
|
|
|||
|
|
@ -19,6 +19,10 @@ import 'dart:async';
|
|||
final downloadManager = DownloadManager();
|
||||
|
||||
class DownloadManager {
|
||||
// DownloadManager currently only supports android
|
||||
static bool get isSupported => Platform.isAndroid;
|
||||
|
||||
|
||||
//Platform channels
|
||||
static MethodChannel platform = const MethodChannel('f.f.freezer/native');
|
||||
static EventChannel eventChannel =
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:audio_service/audio_service.dart';
|
||||
import 'package:audio_session/audio_session.dart';
|
||||
import 'package:equalizer/equalizer.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:freezer/api/cache.dart';
|
||||
import 'package:freezer/api/deezer.dart';
|
||||
|
|
@ -430,12 +431,15 @@ class AudioPlayerTask extends BaseAudioHandler {
|
|||
_box = await Hive.openLazyBox('playback',
|
||||
path: (await getTemporaryDirectory()).path);
|
||||
|
||||
_player = AudioPlayer(
|
||||
handleInterruptions: !initArgs.ignoreInterruptions,
|
||||
androidApplyAudioAttributes: true,
|
||||
handleAudioSessionActivation: true,
|
||||
);
|
||||
|
||||
if (initArgs.ignoreInterruptions) {
|
||||
_player = AudioPlayer(handleInterruptions: false);
|
||||
session.interruptionEventStream.listen((_) {});
|
||||
session.becomingNoisyEventStream.listen((_) {});
|
||||
} else {
|
||||
_player = AudioPlayer();
|
||||
}
|
||||
|
||||
//Update track index
|
||||
|
|
@ -454,6 +458,8 @@ class AudioPlayerTask extends BaseAudioHandler {
|
|||
_eventSub = _player.playbackEventStream.listen((event) {
|
||||
//Update
|
||||
_broadcastState();
|
||||
}, onError: (Object e, StackTrace st) {
|
||||
print('A stream error occurred: $e');
|
||||
});
|
||||
_player.processingStateStream.listen((state) {
|
||||
switch (state) {
|
||||
|
|
@ -462,7 +468,7 @@ class AudioPlayerTask extends BaseAudioHandler {
|
|||
if (_queueIndex == queue.value.length - 1) {
|
||||
customEvent.add({
|
||||
'action': 'queueEnd',
|
||||
'queueSource': (queueSource ?? const QueueSource()).toJson()
|
||||
'queueSource': queueSource!.toJson()
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
|
@ -766,7 +772,7 @@ class AudioPlayerTask extends BaseAudioHandler {
|
|||
//Load in just_audio
|
||||
try {
|
||||
await _player.setAudioSource(_audioSource,
|
||||
initialIndex: _queueIndex, initialPosition: Duration.zero);
|
||||
initialIndex: _queueIndex, initialPosition: Duration.zero, preload: kIsWeb || defaultTargetPlatform != TargetPlatform.linux);
|
||||
} catch (e) {
|
||||
//Error loading tracks
|
||||
}
|
||||
|
|
|
|||
|
|
@ -417,6 +417,8 @@ class _MainScreenState extends State<MainScreen>
|
|||
}
|
||||
|
||||
void _setupUniLinks() async {
|
||||
// supported only on android for now
|
||||
if (!Platform.isAndroid) return;
|
||||
//Listen to URLs
|
||||
_urlLinkStream = linkStream.listen((String? link) {
|
||||
if (link == null) return;
|
||||
|
|
@ -443,6 +445,8 @@ class _MainScreenState extends State<MainScreen>
|
|||
// Movement to navigation bar and back
|
||||
if ((event is RawKeyUpEvent && textFieldVisited) ||
|
||||
event is RawKeyDownEvent) {
|
||||
// only handl if we're running on android
|
||||
if (event.data is! RawKeyEventDataAndroid) return;
|
||||
int keyCode = (event.data as RawKeyEventDataAndroid).keyCode;
|
||||
_logger.fine('KEY PRESSED: $keyCode');
|
||||
switch (keyCode) {
|
||||
|
|
|
|||
|
|
@ -165,6 +165,7 @@ class LibraryScreen extends StatelessWidget {
|
|||
));
|
||||
},
|
||||
),
|
||||
if (DownloadManager.isSupported)
|
||||
ExpansionTile(
|
||||
title: Text('Statistics'.i18n),
|
||||
leading: const LeadingIcon(Icons.insert_chart, color: Colors.grey),
|
||||
|
|
|
|||
|
|
@ -403,10 +403,8 @@ class PlayPauseButton extends StatefulWidget {
|
|||
|
||||
class _PlayPauseButtonState extends State<PlayPauseButton>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late final AnimationController _controller = AnimationController(
|
||||
vsync: this, duration: const Duration(milliseconds: 200));
|
||||
late final Animation<double> _animation =
|
||||
CurvedAnimation(parent: _controller, curve: Curves.easeInOut);
|
||||
late final AnimationController _controller;
|
||||
late final Animation<double> _animation;
|
||||
late StreamSubscription _subscription;
|
||||
late bool _canPlay = audioHandler.playbackState.value.playing ||
|
||||
audioHandler.playbackState.value.processingState ==
|
||||
|
|
@ -414,6 +412,10 @@ class _PlayPauseButtonState extends State<PlayPauseButton>
|
|||
|
||||
@override
|
||||
void initState() {
|
||||
_controller = AnimationController(
|
||||
vsync: this, duration: const Duration(milliseconds: 200));
|
||||
_animation = CurvedAnimation(parent: _controller, curve: Curves.easeInOut);
|
||||
|
||||
_subscription = audioHandler.playbackState.listen((playbackState) {
|
||||
if (playbackState.playing ||
|
||||
playbackState.processingState == AudioProcessingState.ready) {
|
||||
|
|
|
|||
|
|
@ -755,10 +755,10 @@ packages:
|
|||
dependency: "direct main"
|
||||
description:
|
||||
name: just_audio_mpv
|
||||
sha256: "98ac36712f3fe4fb0cf545f29c250fbd55e52c8445a4b0a4ee0bc9322f192797"
|
||||
sha256: d6e4e9fd20bfb9d2fd5e3dcd7906c90ed07f83d1d2f44f31204160821ab62fed
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.1.6"
|
||||
version: "0.1.7"
|
||||
just_audio_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ dependencies:
|
|||
ref: main
|
||||
logging: ^1.2.0
|
||||
just_audio: ^0.9.35
|
||||
just_audio_mpv: ^0.1.6
|
||||
just_audio_mpv: ^0.1.7
|
||||
just_audio_windows: ^0.2.0
|
||||
rxdart: ^0.27.7
|
||||
flutter_isolate: ^2.0.4
|
||||
|
|
|
|||
Loading…
Reference in a new issue