-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
metro theme albums view fixed player not going to next track in queue for ogg enable autoresizing columns in tables
- Loading branch information
1 parent
8d9c275
commit 9b61cc9
Showing
13 changed files
with
260 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
desktop/src/main/kotlin/com/github/wakingrufus/jamm/desktop/AlbumsView.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.github.wakingrufus.jamm.desktop | ||
|
||
import com.github.wakingrufus.jamm.common.AlbumKey | ||
import com.github.wakingrufus.jamm.common.Track | ||
import com.github.wakingrufus.javafx.* | ||
import javafx.beans.property.ReadOnlyListWrapper | ||
import javafx.beans.property.SimpleObjectProperty | ||
import javafx.collections.FXCollections | ||
import javafx.scene.layout.BorderPane | ||
import javafx.scene.layout.HBox | ||
import javafx.scene.layout.StackPane | ||
|
||
class AlbumsView(val library: ObservableLibrary, val mediaPlayer: MediaPlayerController) : BorderPane(), Logging { | ||
val tracks = FXCollections.observableArrayList<Track>() | ||
val selectedAlbum = SimpleObjectProperty<AlbumKey>().also { | ||
it.onChange { | ||
tracks.clear() | ||
tracks.setAll(library.albumTracks[it]?.sortedBy { it.trackNumber }) | ||
} | ||
} | ||
|
||
init { | ||
top<HBox> { | ||
button("Play Random Album") { | ||
this.action { | ||
library.albumList.random().also { | ||
mediaPlayer.play(library.albumTracks.get(it)?.sortedBy { it.trackNumber }.orEmpty()) | ||
} | ||
} | ||
} | ||
} | ||
left<StackPane> { | ||
listview(library.albumList) { | ||
this.cellFactory = CustomStringCellFactory { it.albumName + " - " + it.albumArtist } | ||
bindSelected(selectedAlbum) | ||
} | ||
} | ||
center<BorderPane> { | ||
center<BorderPane> { | ||
center<StackPane> { | ||
tableView(ReadOnlyListWrapper(tracks)) { | ||
column<Track, String>("#") { it.value.trackNumber.toString().toProperty() } | ||
column<Track, String>("Title") { it.value.title.toProperty() } | ||
column<Track, String>("Album") { it.value.album.toProperty() } | ||
column<Track, String>("Album Artist") { it.value.albumArtist.name.toProperty() } | ||
autoResize() | ||
} | ||
} | ||
bottom<HBox> { | ||
button("Play") { | ||
action { | ||
mediaPlayer.play(tracks) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
118 changes: 73 additions & 45 deletions
118
desktop/src/main/kotlin/com/github/wakingrufus/jamm/desktop/Jamm.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,132 @@ | ||
package com.github.wakingrufus.jamm.desktop | ||
|
||
import com.github.wakingrufus.jamm.common.AlbumKey | ||
import com.github.wakingrufus.jamm.common.Track | ||
import com.github.wakingrufus.javafx.* | ||
import javafx.application.Application | ||
import javafx.beans.property.SimpleStringProperty | ||
import javafx.collections.FXCollections | ||
import javafx.event.EventHandler | ||
import javafx.geometry.Side | ||
import javafx.scene.control.Tab | ||
import javafx.scene.control.TabPane | ||
import javafx.scene.control.TextInputDialog | ||
import javafx.scene.layout.BorderPane | ||
import javafx.scene.layout.HBox | ||
import javafx.scene.layout.VBox | ||
import javafx.stage.Stage | ||
import jfxtras.styles.jmetro.JMetro | ||
import jfxtras.styles.jmetro.JMetroStyleClass | ||
import jfxtras.styles.jmetro.Style | ||
import java.io.File | ||
import java.nio.file.Paths | ||
import java.util.prefs.Preferences | ||
|
||
|
||
class Jamm : Application(), Logging { | ||
|
||
val observableLibrary: ObservableLibrary = ObservableLibrary() | ||
val libraryPath: SimpleStringProperty = SimpleStringProperty( | ||
Preferences.userNodeForPackage(Jamm::class.java) | ||
.get("library.path", File(System.getProperty("user.home")).resolve("Music").path | ||
)) | ||
|
||
override fun start(primaryStage: Stage) { | ||
logger().info("starting") | ||
var artistsTab: Tab? = null | ||
var playlistsTab: Tab? = null | ||
val playQueue = FXCollections.observableArrayList<Track>() | ||
// var library = Library() | ||
val mediaPlayerView = MediaPlayerView(playQueue) | ||
val mediaPlayerController = object : MediaPlayerController { | ||
override fun play(tracks: List<Track>) { | ||
logger().info("adding ${tracks.size} to queue") | ||
playQueue.clear() | ||
playQueue.setAll(tracks) | ||
mediaPlayerView.play() | ||
} | ||
|
||
override fun queue(tracks: List<Track>) { | ||
logger().info("adding ${tracks.size} to queue") | ||
playQueue.addAll(tracks) | ||
mediaPlayerView.play() | ||
} | ||
} | ||
|
||
|
||
primaryStage.scene = scene<BorderPane>(width = 1920.0, height = 1080.0) { | ||
this.styleClass.add(JMetroStyleClass.BACKGROUND) | ||
top<VBox> { | ||
menuBar { | ||
menu("Settings") { | ||
item("Music Library...") { | ||
this.onAction = EventHandler { | ||
val pref = Preferences.userNodeForPackage(Jamm::class.java) | ||
val current = pref.get( | ||
"library.path", | ||
File(System.getProperty("user.home")).resolve("Music").path | ||
) | ||
val dialog: TextInputDialog = TextInputDialog(current).apply { | ||
this.title = "Library Path" | ||
} | ||
dialog.contentText = "This is a sample dialog" | ||
val path = dialog.showAndWait() | ||
path.ifPresent { | ||
libraryPath.set(it) | ||
scan() | ||
pref.put("library.path", it) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
center<TabPane> { | ||
playlistsTab = Tab("Playlists") | ||
artistsTab = Tab("Album Artists") | ||
this.tabs.add(playlistsTab) | ||
this.tabs.add(artistsTab) | ||
tab("Playlists") { | ||
PlaylistView(observableLibrary) | ||
} | ||
tab("Album Artists") { | ||
AlbumArtistView(observableLibrary, mediaPlayerController) | ||
} | ||
tab("Albums") { | ||
AlbumsView(observableLibrary, mediaPlayerController) | ||
} | ||
this.side = Side.LEFT | ||
} | ||
val playNextQueue: () -> Unit = { | ||
|
||
} | ||
right<BorderPane> { | ||
top<BorderPane> { | ||
this.center = MediaPlayerView(playQueue) | ||
this.center = mediaPlayerView | ||
} | ||
center<VBox> { | ||
label("Play Queue") | ||
add<VBox> { | ||
this.spacing = 10.0 | ||
this.children.bind(playQueue) { track -> | ||
VBox().apply { | ||
style = "-fx-border-color: white; -fx-border-style: solid; -fx-border-width: 1px;" | ||
label(track.title) { style = "-fx-text-alignment: center;" } | ||
label(track.albumArtist.name) { | ||
style = "-fx-font-weight: bold; -fx-text-alignment: center;" | ||
} | ||
label(track.album) { style = "-fx-font-style: italic; -fx-text-alignment: center;" } | ||
} | ||
} | ||
} | ||
} | ||
} | ||
bottom<HBox> { | ||
|
||
buttonBar { | ||
button("Load") { | ||
action { | ||
val libraryDir = File(System.getProperty("user.home")) | ||
.resolve("Music") | ||
if (!libraryDir.exists()) { | ||
logger().error("Music directory not found") | ||
} else { | ||
// GlobalScope.launch(Dispatchers.IO) { | ||
// library = scan(libraryDir) | ||
// library.warnings.forEach { | ||
// logger().warn(it) | ||
// } | ||
// library.errors.forEach { | ||
// logger().error(it) | ||
// } | ||
observableLibrary.scan(libraryDir) | ||
// } | ||
// logger().info("tracks: ${observableLibrary.trackCount}") | ||
logger().info("album artists: ${observableLibrary.albumArtistsAlbums.keys.size}") | ||
artistsTab?.content = AlbumArtistView(observableLibrary, mediaPlayerController) | ||
playlistsTab?.content = PlaylistView(observableLibrary) | ||
this.children.add(HBox().apply { | ||
label(track.albumArtist.name) { | ||
style = "-fx-font-weight: bold; -fx-text-alignment: center;" | ||
} | ||
label(" - ") | ||
label(track.album) { style = "-fx-font-style: italic; -fx-text-alignment: center;" } | ||
}) | ||
|
||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
val jMetro = JMetro(Style.DARK) | ||
jMetro.scene = primaryStage.scene | ||
primaryStage.show() | ||
scan() | ||
} | ||
|
||
fun scan() { | ||
val f = Paths.get(libraryPath.value).toFile() | ||
if (!f.exists()) { | ||
logger().error("Music directory not found") | ||
} else { | ||
observableLibrary.scan(f) | ||
} | ||
} | ||
} |
10 changes: 0 additions & 10 deletions
10
desktop/src/main/kotlin/com/github/wakingrufus/jamm/desktop/Launcher.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.