Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
J4yJ4y-R6 committed Feb 4, 2021
2 parents 1650e26 + 5801bd1 commit 121b326
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 32 deletions.
20 changes: 15 additions & 5 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@

# Spotify Music Party
# _![app_icon](app/src/main/res/mipmap-mdpi/ic_music_party_greenbg_round.png)_ Spotify Music Party ![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/JanielGamer/SpotifyMusicParty?include_prereleases&color=457855) ![GitHub all releases](https://img.shields.io/github/downloads/JanielGamer/SpotifyMusicParty/total) ![GitHub repo size](https://img.shields.io/github/repo-size/JanielGamer/SpotifyMusicParty)

We made this Android application to provide a custom version of a MusicParty. Our idea was to set on simple Server-Client model, where only the Server is able to play the music.

## Installation

### With Gradle

1. Go to the [Spotify Developer Page](https://developer.spotify.com/dashboard/) and create a application to get a. `Client ID` and a `Client Secret` (These will be needed if you wand to build the app local).
**Important:** You have to add your and fingerprint to the application in the developper page.

**Important:** You have to add your [development fingerprint](https://developers.google.com/android/guides/client-auth) to the application in the developper page.

2. Clone the repository.
3. Rename the `apikey.properties.example` file to `apikey.properties` and add you previously gained `Client ID` and `Client Secret` at the right row inside the quotation marks.
4. Now you can use the default gradle build and debug commands.

### With the APK
1. Donwload the APK of the latest stable [release](https://github.com/JanielGamer/SpotifyMusicParty/releases/latest)
2. Install the obtained APK by opening it
4. Have fun and use the app

### Android requirements
- `Android SDK >= 30`
- The spotify app has to be installed for hosting a server
- `Android SDK >= 27`
- The spotify app has to be installed for hosting a server (Server on AVD is not working)

## Functionalities

Expand Down Expand Up @@ -71,5 +81,5 @@ We made this Android application to provide a custom version of a MusicParty. Ou
- Thumb-Up: Vote Yes
- Thumb-Down: Vote No
- X-Button: Ignore
- Exit: Toolbar 5. Button
- Exit: Toolbar 3. Button
- Leave the party
37 changes: 16 additions & 21 deletions app/src/main/java/com/tinf19/musicparty/server/HostActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,6 @@ public interface HostActivityCallback {
void afterFailure();
}

BroadcastReceiver exitReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "HostActivitiy started: afterNotification called exit");
animateFragmentChange(true, hostClosePartyFragment, "ExitConnectionFragment");
}
};


//Android lifecycle methods

@Override
Expand All @@ -171,8 +162,6 @@ protected void onCreate(Bundle savedInstanceState) {

setContentView(R.layout.activity_host);

registerReceiver(exitReceiver, new IntentFilter(Constants.STOP));

hostSearchBarFragment = new HostSearchBarFragment(new HostSearchBarFragment.HostSearchBarCallback() {
@Override
public void searchForSongs(List<Track> tracks) {
Expand Down Expand Up @@ -382,13 +371,6 @@ public Track getCurrentPlaying() {

@Override
public void swapPlaylistItems(int from, int to) {
/*if (mBoundService != null) {
try {
mBoundService.moveItem(from, to);
} catch (JSONException e) {
e.printStackTrace();
}
}*/
if (mBoundService != null) {
mBoundService.swapItem(from, to);
}
Expand Down Expand Up @@ -491,8 +473,13 @@ public void stopTimer() {
if(!getIntent().getBooleanExtra(Constants.FROM_NOTIFICATION, false) && loadingFragment != null)
getSupportFragmentManager().beginTransaction().
replace(R.id.showSongHostFragmentFrame, loadingFragment, "LoadingFragment").commitAllowingStateLoss();
else
else {
showDefaultFragments();
if (getIntent().getBooleanExtra(Constants.STOP, false)) {
Log.d(TAG, "HostActivity started: afterNotification called exit");
animateFragmentChange(true, hostClosePartyFragment, "ExitConnectionFragment");
}
}

}

Expand Down Expand Up @@ -854,8 +841,16 @@ void doUnbindService() {
public void stopService() {
Log.d(TAG, "spotify remote control disconnected");
if(mBoundService != null && mBoundService.getmSpotifyAppRemote() != null) {
mBoundService.getmSpotifyAppRemote().getPlayerApi().pause();
SpotifyAppRemote.disconnect(mBoundService.getmSpotifyAppRemote());
SpotifyAppRemote spotifyAppRemote = mBoundService.getmSpotifyAppRemote();
new Thread(() -> {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
Log.e(TAG, e.getMessage(), e);
}
spotifyAppRemote.getPlayerApi().pause();
SpotifyAppRemote.disconnect(spotifyAppRemote);
}).start();
}
doUnbindService();
stopService(new Intent(this, HostService.class));
Expand Down
21 changes: 16 additions & 5 deletions app/src/main/java/com/tinf19/musicparty/server/HostService.java
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,10 @@ public void notificationVotedNo(int id) {
.putExtra(Constants.FROM_NOTIFICATION, true);
pendingIntent = PendingIntent.getActivity(this,
0, notificationIntent, 0);
Intent intentAction = new Intent(this, ActionReceiver.class);
pendingIntentButton = PendingIntent.getBroadcast(this,1,intentAction,PendingIntent.FLAG_UPDATE_CURRENT);
Intent intentAction = new Intent(this, HostActivity.class)
.putExtra(Constants.FROM_NOTIFICATION, true)
.putExtra(Constants.STOP, true);
pendingIntentButton = PendingIntent.getActivity(this,1,intentAction,PendingIntent.FLAG_UPDATE_CURRENT);

Notification notification = new NotificationCompat.Builder(this, Constants.CHANNEL_ID)
.setContentTitle(getString(R.string.service_serverMsg, partyName))
Expand Down Expand Up @@ -1282,7 +1284,7 @@ public void run() {
*/
private void stopAll() throws IOException {
for(CommunicationThread client : clientThreads) {
client.sendMessage(Commands.QUIT, "Session has been closed");
client.sendStop();
client.close();
}
}
Expand Down Expand Up @@ -1384,6 +1386,12 @@ public void sendMessage(Commands command, String message) {
}
}

public void sendStop() throws IOException {
Log.d(TAG, "Send QUIT Message to User: " + username + ", MESSAGE: Session has been closed");
out.writeBytes(Constants.DELIMITER + Commands.QUIT.toString() + Constants.DELIMITER + "Session has been closed" + "\n\r");
out.flush();
}

/**
* Sending a command and a message to a client
* @param command Communication command for actions in the client
Expand Down Expand Up @@ -1531,7 +1539,10 @@ public void run() {
}
}
}
} catch (IOException | JSONException e) {
} catch (IOException e) {
Log.d(TAG,"Client ist not connected anymore");
return;
} catch (JSONException e) {
Log.e(TAG, e.getMessage(), e);
return;
}
Expand Down Expand Up @@ -1574,7 +1585,7 @@ public void handleMessage(Message msg) {
try {
CommunicationThread.this.sendMessageLooper(Commands.valueOf(command), (String) message);
} catch (IOException e) {
Log.e(TAG, e.getMessage(), e);
Log.d(TAG,"Client ist not connected anymore");
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@

<string name="notification_votingTitle">Voting zum Lied: %1$s</string>
<string name="notification_votingMessageSecondLine">Vote jetzt zum Hinzufügen des Liedes zu der aktuellen Queue.</string>
<string name="info_text">Hallo zur MusicParty-App, \nwir verändern, wie du feierst. Du kannst über das Menü eine Party erstellen oder einer Party deiner Freunde beitreten. Dazu brauchst du einen QR-Code, einen Link oder die Zugangsdaten bestehend aus IP-Adresse und Passwort. \nEine Liste aller Funktionalitäten findest du unter: <a href="https://github.com/JanielGamer/SpotifyMusicParty/blob/master/README.MD">GitHub</a> \nEinige Funktionen, die du vielleicht von Spotify gewöhnt bist, konnte wir noch nicht genauso in unserer App umsetzen. Beispielsweise empfehlen wir dir das Überspringen und Zurückgehen von Liedern nur über den Knopf in unserer App und nicht über die Schaltflächen der Spotify-App. \nJetzt wünschen wir dir viel Spaß bei deiner ersten Party.</string>
<string name="info_text">Hallo zur MusicParty-App, \nwir verändern, wie du feierst. Du kannst über das Menü eine Party erstellen oder einer Party deiner Freunde beitreten. Dazu brauchst du einen QR-Code, einen Link oder die Zugangsdaten bestehend aus IP-Adresse und Passwort. \nEine Liste aller Funktionalitäten findest du unter: <a href="https://github.com/JanielGamer/SpotifyMusicParty/blob/master/README.MD#Functionalities">GitHub</a> \nEinige Funktionen, die du vielleicht von Spotify gewöhnt bist, konnte wir noch nicht genauso in unserer App umsetzen. Beispielsweise empfehlen wir dir das Überspringen und Zurückgehen von Liedern nur über den Knopf in unserer App und nicht über die Schaltflächen der Spotify-App. \nJetzt wünschen wir dir viel Spaß bei deiner ersten Party.</string>



Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
o/jetified-spotify-auth-release-1.2.3-runtime
Binary file not shown.

0 comments on commit 121b326

Please sign in to comment.