Skip to content

Commit

Permalink
Merge pull request #2 from SaturnMusic/merge-upstream
Browse files Browse the repository at this point in the history
Merge upstream V2
  • Loading branch information
bw8686 authored Sep 15, 2024
2 parents 04ca965 + b09edbd commit 025bfab
Show file tree
Hide file tree
Showing 39 changed files with 651 additions and 965 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,7 @@ app.*.map.json
# Envied
.env
lib/utils/env.g.dart

# Possible translations remnants
translations/refreezer.zip
translations/ReFreezer (translations).zip
Binary file modified assets/fonts/ReFreezerIcons.ttf
Binary file not shown.
Binary file removed assets/screenshots/DownloadFinished.jpg
Binary file not shown.
Binary file removed assets/screenshots/DownloadRunning.jpg
Binary file not shown.
Binary file removed assets/screenshots/Home.jpg
Binary file not shown.
Binary file removed assets/screenshots/Library.jpg
Binary file not shown.
Binary file removed assets/screenshots/Login.jpg
Binary file not shown.
Binary file removed assets/screenshots/Lyrics.jpg
Binary file not shown.
Binary file removed assets/screenshots/Player.jpg
Binary file not shown.
Binary file removed assets/screenshots/PlayerHorizontal.jpg
Binary file not shown.
Binary file removed assets/screenshots/Search.jpg
Binary file not shown.
Binary file removed assets/screenshots/SearchResults.jpg
Binary file not shown.
35 changes: 16 additions & 19 deletions lib/api/clubs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'dart:io';
import 'package:http/http.dart' as http;
import 'package:path_provider/path_provider.dart';
import 'package:path/path.dart' as p;
import 'package:socket_io_client/socket_io_client.dart' as IO;
import 'package:socket_io_client/socket_io_client.dart' as io;
import 'package:get_it/get_it.dart';

import '../api/deezer.dart';
Expand Down Expand Up @@ -117,9 +117,7 @@ class ClubRoom {
positionTime,
);
final room = jsonDecode(_joinResponse);
print(room.toString());
var user = room?['users']?.firstWhere((u) => u['sid'] == sid, orElse: () => null);
print(user.toString());
// return user != null && user['admin'] == true;
if (user['admin'] == true) {
allowcontrols = true;
Expand All @@ -130,7 +128,7 @@ class ClubRoom {

Future<List<Track>> _convertJsonToTracks(List<String> trackIds) async {
try {
final apicall = await deezerAPI.callGwApi('song.getlistdata', params: {"sng_ids": trackIds});
final apicall = await deezerAPI.callGwApi('song.getlistdata', params: {'sng_ids': trackIds});
final Map<String, dynamic> decodedJson = apicall;
final List<dynamic> trackDataList = decodedJson['results']['data'];
final List<Track> trackList = trackDataList.map((trackData) {
Expand All @@ -156,12 +154,12 @@ class ClubRoom {
}

class SocketManagement {
late final IO.Socket socket;
late final io.Socket socket;
final String address;
final ClubRoom clubRoom;

SocketManagement({required this.address, required this.clubRoom}) {
socket = IO.io(address, IO.OptionBuilder()
socket = io.io(address, io.OptionBuilder()
.setTransports(['websocket'])
.disableAutoConnect()
.build());
Expand Down Expand Up @@ -241,7 +239,7 @@ class SocketManagement {

socket.on('request', (data) async {
print(data);
final res = await deezerAPI.callGwApi("deezer.pageTrack", params: {"sng_id": data['id']['SNG_ID']});
final res = await deezerAPI.callGwApi('deezer.pageTrack', params: {'sng_id': data['id']['SNG_ID']});
print(res);
final Map<String, dynamic> reqtrack = res['results']['DATA'];
datamgmt.addreq(Track.fromPrivateJson(reqtrack));
Expand All @@ -254,7 +252,7 @@ class SocketManagement {
});

socket.on('addQueue', (data) async {
print("addqueue");
print('addqueue');
var trackId = data['track'];
var next = data['next'];
List<String> trackIds = [trackId];
Expand Down Expand Up @@ -284,13 +282,12 @@ class SocketManagement {
throw Exception('Unexpected type for position: ${positionDynamic.runtimeType}');
}
await GetIt.I<AudioPlayerHandler>().ClubSync(playing, position, timestamp);
print("sync");
print('sync');
});

socket.on('index', (data) async {
var index = data['index'];
await GetIt.I<AudioPlayerHandler>().skipToQueueItem(index);
print("index");
});
}

Expand Down Expand Up @@ -347,10 +344,10 @@ class SocketManagement {
}

sync() async {
if (!await clubRoom.ifclub()) return;
if (clubRoom.ifclub()) return;
bool playing = await GetIt.I<AudioPlayerHandler>().playing();
Duration position = await GetIt.I<AudioPlayerHandler>().position();
bool admin = await clubRoom.ifhost();
bool admin = clubRoom.ifhost();
socket.emit('sync', {
'playing': playing,
'position': position.inMilliseconds, // Convert Duration to milliseconds
Expand All @@ -360,7 +357,7 @@ sync() async {
}

addQueue(track, bool next) {
print("addqueue emitted for track:" + track.id.toString() + next.toString());
print('addqueue emitted for track:' + track.id.toString() + next.toString());
if (!clubRoom.ifclub()) return();
if (!clubRoom.ifhost()) return();
//Emit
Expand All @@ -371,7 +368,7 @@ sync() async {
}

addQueueID(String id, bool next) {
print("addqueue emitted for track:" + id.toString() + next.toString());
print('addqueue emitted for track:' + id.toString() + next.toString());
if (!clubRoom.ifclub()) return();
if (!clubRoom.ifhost()) return();
//Emit
Expand All @@ -382,8 +379,8 @@ sync() async {
}

playIndex(int i) async {
if (!await clubRoom.ifclub()) return;
if (!await clubRoom.ifhost()) return;
if (clubRoom.ifclub()) return;
if (clubRoom.ifhost()) return;
socket.emit('index', i);
bool isPlaying = await GetIt.I<AudioPlayerHandler>().playing();
if (isPlaying) {
Expand Down Expand Up @@ -414,7 +411,7 @@ sync() async {
if (!clubRoom.ifhost()) return;
//Next track
await playIndex(realqueuenumber + 1);
await Future.delayed(Duration(seconds: 5));
await Future.delayed(const Duration(seconds: 5));
await playIndex(realqueuenumber + 1);
await rundesktopcompat();
await togglePlayback(true);
Expand Down Expand Up @@ -443,15 +440,15 @@ sync() async {
}

Future songRequest(String id) async {
final res = await deezerAPI.callGwApi("deezer.pageTrack", params: {"sng_id": id});
final res = await deezerAPI.callGwApi('deezer.pageTrack', params: {'sng_id': id});
socket.emit('request', {
'id': res['results']['DATA'],
});
}

//Remove request
Future removeRequest(String id) async {
print("rmrequest emitted for track:" + id);
print('rmrequest emitted for track:' + id);
if (!clubRoom.ifhost()) return;
datamgmt.removereq(id);
socket.emit('removeRequest', id.toString());
Expand Down
Loading

0 comments on commit 025bfab

Please sign in to comment.