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