Skip to content

Commit 58c98c9

Browse files
committed
Media Player Enhancements finished.
1 parent debfde5 commit 58c98c9

File tree

11 files changed

+59
-18
lines changed

11 files changed

+59
-18
lines changed

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Client/src/main/java/controllers/io/cache/file/StaticFileCacheService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ public class StaticFileCacheService implements FileCacheService {
2424

2525
private File rootFile = null;
2626

27+
/**
28+
* Workaround: This field marks the cache as "USED".
29+
* This is a workaround for the MediaPlayer to detect, if the song was already played.
30+
*/
2731
private final AtomicBoolean cacheWasUsed = new AtomicBoolean();
2832

2933
/**
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package controllers.media;
2+
3+
import controllers.io.cache.CacheService;
4+
import models.songs.Song;
5+
6+
/**
7+
* <pre>
8+
* Created by Esteban Luchsinger on 24.04.2016.
9+
* This <code>MediaPlayer</code> uses a cache as a source for the Media.
10+
* </pre>
11+
*/
12+
public class CachedMediaPlayer {
13+
14+
private final CacheService cacheService;
15+
16+
public CachedMediaPlayer(CacheService cacheService) {
17+
this.cacheService = cacheService;
18+
}
19+
20+
/**
21+
* Plays a song.
22+
* If this song is already cached, it plays it from the cache.
23+
* If the song is not yet cached, it will cache it first.
24+
* @param song
25+
*/
26+
public void play(Song song) {
27+
28+
}
29+
30+
/**
31+
* Pauses the current MediaPlayer from playing a song.
32+
*/
33+
public void pause() {
34+
35+
}
36+
37+
public void stop() {
38+
39+
}
40+
41+
}

Client/src/main/java/controllers/networking/streaming/music/tcp/TCPMusicStreamingController.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ else if(receivedObject instanceof PlayCommand) {
202202
}
203203
else if(receivedObject instanceof PauseCommand) {
204204
this.logger.info("Received PauseCommand");
205-
PauseCommand command = (PauseCommand) receivedObject;
206205
this.onPauseCommandReceived();
207206
}
208207
// A stop command

Server/src/main/java/controllers/media/MediaPlayer.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@
1313
*/
1414
public interface MediaPlayer<T> {
1515

16-
// /**
17-
// * Plays a track and tries to resume it, if desired.
18-
// * @param track Track to play.
19-
// * @param tryResume Set this true, if the track should be resumed (only if possible).
20-
// */
21-
// void play(T track, boolean tryResume);
22-
2316
/**
2417
* Plays a track.
2518
* @param track The track to play.

Server/src/main/java/controllers/media/music/BaseAudioPlayer.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package controllers.media.music;
22

3+
import controllers.media.MediaPlayer;
34
import javafx.beans.property.*;
45
import javafx.util.Duration;
5-
import viewmodels.songs.PlayableSong;
6+
import models.songs.PlayableSong;
67

78
import java.util.List;
89

@@ -12,7 +13,7 @@
1213
* This is a base class for an audio player. It provides the needed properties.
1314
* </pre>
1415
*/
15-
public abstract class BaseAudioPlayer implements controllers.media.MediaPlayer<PlayableSong> {
16+
public abstract class BaseAudioPlayer implements MediaPlayer<PlayableSong> {
1617

1718
private BooleanProperty isPlaying;
1819
private ObjectProperty<Duration> currentMediaTime;

Server/src/main/java/controllers/media/music/NetworkAudioPlayer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
import javafx.collections.ObservableList;
66
import javafx.scene.media.Media;
77
import javafx.scene.media.MediaPlayer;
8+
import models.songs.PlayableSong;
89
import models.songs.Song;
910
import org.slf4j.Logger;
1011
import org.slf4j.LoggerFactory;
11-
import viewmodels.songs.PlayableSong;
1212

1313
import java.io.File;
1414
import java.io.IOException;

Server/src/main/java/viewmodels/MainWindowViewModel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
import models.networking.clients.NetworkClient;
2626
import models.networking.dtos.RenameCommand;
2727
import models.songs.Mp3Song;
28+
import models.songs.PlayableMp3Song;
29+
import models.songs.PlayableSong;
2830
import models.songs.Song;
2931
import org.slf4j.Logger;
3032
import org.slf4j.LoggerFactory;
3133
import utils.DurationStringConverter;
32-
import viewmodels.songs.PlayableMp3Song;
33-
import viewmodels.songs.PlayableSong;
3434

3535
import java.io.Closeable;
3636
import java.io.File;

Server/src/main/java/viewmodels/SongTableRow.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package viewmodels;
22

33
import javafx.scene.control.TableRow;
4-
import viewmodels.songs.PlayableSong;
4+
import models.songs.PlayableSong;
55

66
/**
77
* <pre>

Server/src/main/java/viewmodels/songs/PlayableMp3Song.java renamed to Shared/src/main/java/models/songs/PlayableMp3Song.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
package viewmodels.songs;
1+
package models.songs;
22

33
import com.mpatric.mp3agic.InvalidDataException;
44
import com.mpatric.mp3agic.UnsupportedTagException;
55
import javafx.beans.property.BooleanProperty;
66
import javafx.beans.property.SimpleBooleanProperty;
7-
import models.songs.Mp3Song;
87

98
import java.io.IOException;
109

0 commit comments

Comments
 (0)