Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
KRTirtho committed Mar 24, 2023
2 parents 3f5a1b9 + f160ec7 commit 7a0fd64
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 40 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@

# 🚨 DO NOT INSTALL Spotube FROM `PLAY STORE`
## There's an unofficial + `illegal` clone/copycat of Spotube available on `Play Store` that is full of malware, ads and trackers. To help take down this illegal copycat/clone, please FOLLOW THIS GUIDE : [wiki/Report-Spotube-Copycat-on-PlayStore](https://github.com/KRTirtho/spotube/wiki/Report-Spotube-Copycat-on-Playstore)

Follow this issue thread to get updates on the progress of the legal action against the illegal copycat/clone: https://github.com/KRTirtho/spotube/issues/448


<p align="center"><img width="700" src="assets/spotube_banner.png" alt="Spotube Logo"></p>

<p align="center">
Expand Down Expand Up @@ -206,7 +213,7 @@ But why? You can learn about it [here](https://dev.to/krtirtho/choosing-open-sou
- [Kingkor Roy Tirtho](https://github.com/KRTirtho) - The Founder, Maintainer and Lead Developer
- [Owen Conor](https://github.com/owencz1998) - The Cool Discord Moderator
- [Piotr Rogowski](https://github.com/karniv00l) - The MacOS Developer
- [RaptaG](https://github.com/raptag) - The Github Moderator and Community Manager
- [RaptaG](https://github.com/raptag) - The GitHub Moderator and Community Manager
- [Rusty Apple](https://github.com/RustyApple) - The Mysterious Unknown Guy

# Social platforms
Expand Down
11 changes: 11 additions & 0 deletions lib/pages/lyrics/lyrics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';

import 'package:spotube/collections/spotube_icons.dart';
import 'package:spotube/components/shared/fallbacks/anonymous_fallback.dart';
import 'package:spotube/components/shared/page_window_title_bar.dart';
import 'package:spotube/components/shared/image/universal_image.dart';
import 'package:spotube/components/shared/themed_button_tab_bar.dart';
Expand All @@ -13,6 +14,7 @@ import 'package:spotube/hooks/use_custom_status_bar_color.dart';
import 'package:spotube/hooks/use_palette_color.dart';
import 'package:spotube/pages/lyrics/plain_lyrics.dart';
import 'package:spotube/pages/lyrics/synced_lyrics.dart';
import 'package:spotube/provider/authentication_provider.dart';
import 'package:spotube/provider/playlist_queue_provider.dart';
import 'package:spotube/utils/platform.dart';
import 'package:spotube/utils/type_conversion_utils.dart';
Expand Down Expand Up @@ -48,6 +50,15 @@ class LyricsPage extends HookConsumerWidget {
],
);

final auth = ref.watch(AuthenticationNotifier.provider);

if (auth == null) {
return Scaffold(
appBar: !kIsMacOS && !isModal ? const PageWindowTitleBar() : null,
body: const AnonymousFallback(),
);
}

if (isModal) {
return DefaultTabController(
length: 2,
Expand Down
53 changes: 28 additions & 25 deletions lib/pages/player/player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import 'package:spotube/hooks/use_custom_status_bar_color.dart';
import 'package:spotube/hooks/use_palette_color.dart';
import 'package:spotube/models/local_track.dart';
import 'package:spotube/pages/lyrics/lyrics.dart';
import 'package:spotube/provider/authentication_provider.dart';
import 'package:spotube/provider/playlist_queue_provider.dart';
import 'package:spotube/provider/user_preferences_provider.dart';
import 'package:spotube/utils/type_conversion_utils.dart';
Expand All @@ -29,6 +30,7 @@ class PlayerView extends HookConsumerWidget {
@override
Widget build(BuildContext context, ref) {
final theme = Theme.of(context);
final auth = ref.watch(AuthenticationNotifier.provider);
final currentTrack = ref.watch(PlaylistQueueNotifier.provider.select(
(value) => value?.activeTrack,
));
Expand Down Expand Up @@ -180,32 +182,33 @@ class PlayerView extends HookConsumerWidget {
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
floatingQueue: false,
extraActions: [
IconButton(
tooltip: "Open Lyrics",
icon: const Icon(SpotubeIcons.music),
onPressed: () {
showModalBottomSheet(
context: context,
isDismissible: true,
enableDrag: true,
isScrollControlled: true,
backgroundColor: Colors.black38,
barrierColor: Colors.black12,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20),
if (auth != null)
IconButton(
tooltip: "Open Lyrics",
icon: const Icon(SpotubeIcons.music),
onPressed: () {
showModalBottomSheet(
context: context,
isDismissible: true,
enableDrag: true,
isScrollControlled: true,
backgroundColor: Colors.black38,
barrierColor: Colors.black12,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20),
),
),
),
constraints: BoxConstraints(
maxHeight:
MediaQuery.of(context).size.height * 0.8,
),
builder: (context) =>
const LyricsPage(isModal: true),
);
},
)
constraints: BoxConstraints(
maxHeight:
MediaQuery.of(context).size.height * 0.8,
),
builder: (context) =>
const LyricsPage(isModal: true),
);
},
)
],
),
PlayerControls(iconColor: paletteColor.bodyTextColor),
Expand Down
2 changes: 2 additions & 0 deletions lib/pages/root/root_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:spotube/components/root/bottom_player.dart';
import 'package:spotube/components/root/sidebar.dart';
import 'package:spotube/components/root/spotube_navigation_bar.dart';
import 'package:spotube/hooks/use_update_checker.dart';
import 'package:spotube/provider/authentication_provider.dart';
import 'package:spotube/provider/downloader_provider.dart';

const rootPaths = {
Expand All @@ -28,6 +29,7 @@ class RootApp extends HookConsumerWidget {
Widget build(BuildContext context, ref) {
final index = useState(0);
final isMounted = useIsMounted();
final auth = ref.watch(AuthenticationNotifier.provider);

final downloader = ref.watch(downloaderProvider);
useEffect(() {
Expand Down
5 changes: 4 additions & 1 deletion lib/provider/playlist_queue_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ class PlaylistQueueNotifier extends PersistedStateNotifier<PlaylistQueue?> {
void configure() async {
if (kIsMobile || kIsMacOS) {
mobileService = await AudioService.init(
builder: () => MobileAudioService(this),
builder: () => MobileAudioService(
this,
ref.read(VolumeProvider.provider.notifier),
),
config: const AudioServiceConfig(
androidNotificationChannelId: 'com.krtirtho.Spotube',
androidNotificationChannelName: 'Spotube',
Expand Down
57 changes: 45 additions & 12 deletions lib/services/mobile_audio_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,28 @@ import 'package:spotube/services/audio_player.dart';
class MobileAudioService extends BaseAudioHandler {
AudioSession? session;
final PlaylistQueueNotifier playlistNotifier;
final VolumeProvider volumeNotifier;

PlaylistQueue? get playlist => playlistNotifier.state;

MobileAudioService(this.playlistNotifier) {
MobileAudioService(this.playlistNotifier, this.volumeNotifier) {
AudioSession.instance.then((s) {
session = s;
session?.configure(const AudioSessionConfiguration.music());
s.interruptionEventStream.listen((event) async {
if (event.type != AudioInterruptionType.duck) {
await playlistNotifier.pause();
switch (event.type) {
case AudioInterruptionType.duck:
await volumeNotifier.setVolume(event.begin ? 0.5 : 1.0);
break;
case AudioInterruptionType.pause:
case AudioInterruptionType.unknown:
await playlistNotifier.pause();
break;
}
});
});
audioPlayer.onPlayerStateChanged.listen((state) async {
if (state != PlayerState.completed) {
playbackState.add(await _transformEvent());
}
playbackState.add(await _transformEvent());
});

audioPlayer.onPositionChanged.listen((pos) async {
Expand All @@ -46,6 +52,27 @@ class MobileAudioService extends BaseAudioHandler {
@override
Future<void> seek(Duration position) => playlistNotifier.seek(position);

@override
Future<void> setShuffleMode(AudioServiceShuffleMode shuffleMode) async {
await super.setShuffleMode(shuffleMode);

if (shuffleMode == AudioServiceShuffleMode.all) {
playlistNotifier.shuffle();
} else {
playlistNotifier.unshuffle();
}
}

@override
Future<void> setRepeatMode(AudioServiceRepeatMode repeatMode) async {
super.setRepeatMode(repeatMode);
if (repeatMode == AudioServiceRepeatMode.all) {
playlistNotifier.loop();
} else {
playlistNotifier.unloop();
}
}

@override
Future<void> stop() async {
await playlistNotifier.stop();
Expand All @@ -71,6 +98,7 @@ class MobileAudioService extends BaseAudioHandler {
}

Future<PlaybackState> _transformEvent() async {
final position = (await audioPlayer.getCurrentPosition()) ?? Duration.zero;
return PlaybackState(
controls: [
MediaControl.skipToPrevious,
Expand All @@ -85,12 +113,17 @@ class MobileAudioService extends BaseAudioHandler {
},
androidCompactActionIndices: const [0, 1, 2],
playing: audioPlayer.state == PlayerState.playing,
updatePosition: (await audioPlayer.getCurrentPosition()) ?? Duration.zero,
processingState: audioPlayer.state == PlayerState.paused
? AudioProcessingState.buffering
: audioPlayer.state == PlayerState.playing
? AudioProcessingState.ready
: AudioProcessingState.idle,
updatePosition: position,
bufferedPosition: position,
shuffleMode: playlist?.isShuffled == true
? AudioServiceShuffleMode.all
: AudioServiceShuffleMode.none,
repeatMode: playlist?.isLooping == true
? AudioServiceRepeatMode.one
: AudioServiceRepeatMode.all,
processingState: playlist?.isLoading == true
? AudioProcessingState.loading
: AudioProcessingState.ready,
);
}
}
2 changes: 1 addition & 1 deletion scripts/update_flathub_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# Requires the 2nd VERSION argument to be passed
version = sys.argv[1:][0]

tar_url = f"https://github.com/{REPO}/releases/download/v{version}/Spotube-linux-x86_64.tar.xz"
tar_url = f"https://github.com/{REPO}/releases/download/v{version}/spotube-linux-{version}-x86_64.tar.xz"
tar_sha256 = hashlib.sha256()
print(f"Downloading file {tar_url} to generete sha256 sum")
tar = requests.get(tar_url)
Expand Down

0 comments on commit 7a0fd64

Please sign in to comment.