Skip to content

Commit

Permalink
Experimental improvements to playback from content url, fix stop beha…
Browse files Browse the repository at this point in the history
…viour after playing queue end
  • Loading branch information
coleblvck committed Jun 8, 2024
1 parent 8b15307 commit 518e7e0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
14 changes: 12 additions & 2 deletions lib/player/utilities/activity_handlers.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//Audio Service
import 'dart:io';
import 'package:just_audio/just_audio.dart';
import 'package:path/path.dart';

import 'package:audio_service/audio_service.dart';
import 'package:audiotags/audiotags.dart';
Expand Down Expand Up @@ -122,15 +124,23 @@ shuffleTracks(List<Track> list) async {
playFromIntentLink(String link) async {
File file = await toFile(link);
Tag? tag = await AudioTags.read(file.path);
AudioPlayer thisAudioLoader = AudioPlayer(
handleInterruptions: false,
androidApplyAudioAttributes: false,
handleAudioSessionActivation: false,
);
final songItem = MediaItem(
id: link,
title: tag?.title ?? "Unknown",
title: tag?.title ?? basename(file.path),
artist: tag?.trackArtist ?? "Unknown Artist",
album: tag?.album ?? "Unknown Album",
artUri: defaultArtUri,
duration: Duration(seconds: tag?.duration ?? 1),
duration: tag?.duration != null
? Duration(seconds: tag!.duration!)
: await thisAudioLoader.setUrl(link),
extras: {
"id": "no-id",
});
thisAudioLoader.dispose();
playOnlyThis(songItem);
}
2 changes: 2 additions & 0 deletions lib/player/utilities/audio_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class AntiiqAudioHandler extends BaseAudioHandler
(state) {
switch (state) {
case ProcessingState.completed:
audioPlayer.stop();
audioPlayer.seek(Duration.zero);
break;
case ProcessingState.ready:
skipState = null;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ packages:
source: hosted
version: "1.6.0"
path:
dependency: transitive
dependency: "direct main"
description:
name: path
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ dependencies:
receive_intent: ^0.2.5
uri_to_file: ^1.0.0
audiotags: ^1.4.0
path: any

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 518e7e0

Please sign in to comment.