Skip to content

Commit

Permalink
Merge pull request #135 from stormdb/issue/81-play-chapter
Browse files Browse the repository at this point in the history
Issue#81, added "play" function in "Chapter" mode
  • Loading branch information
yermak committed Nov 19, 2020
2 parents 8c1f871 + 9418cfd commit f8dd2e1
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/uk/yermak/audiobookconverter/MediaInfoBean.java
@@ -1,8 +1,10 @@
package uk.yermak.audiobookconverter;

import java.util.List;
import java.util.Objects;

public class MediaInfoBean extends MediaInfoOrganiser implements MediaInfo {

private final String fileName;
private int channels;
private int frequency;
Expand Down Expand Up @@ -54,6 +56,10 @@ public long getDuration() {
return this.duration;
}

@Override
public List<MediaInfo> getMedia() {
return List.of(this);
}

public String getFileName() {
return this.fileName;
Expand Down
@@ -1,9 +1,11 @@
package uk.yermak.audiobookconverter;

import java.util.List;
import java.util.Objects;
import java.util.concurrent.Future;

public class MediaInfoProxy implements MediaInfo {

private final String filename;
private final Future<MediaInfo> futureLoad;

Expand Down Expand Up @@ -61,6 +63,11 @@ public void moveDown() {
this.getMediaInfo().moveDown();
}

@Override
public List<MediaInfo> getMedia() {
return getMediaInfo().getMedia();
}

public String getFileName() {
return this.filename;
}
Expand Down
@@ -1,5 +1,6 @@
package uk.yermak.audiobookconverter;

import java.util.List;
import java.util.Objects;

public class MediaTrackAdaptor extends MediaInfoOrganiser implements MediaInfo {
Expand Down Expand Up @@ -49,6 +50,11 @@ public long getDuration() {
return duration;
}

@Override
public List<MediaInfo> getMedia() {
return List.of(mediaInfo);
}

@Override
public String getFileName() {
return mediaInfo.getFileName();
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/uk/yermak/audiobookconverter/Organisable.java
@@ -1,6 +1,9 @@
package uk.yermak.audiobookconverter;

import java.util.List;

public interface Organisable {

String getTitle();

String getDetails();
Expand All @@ -14,4 +17,9 @@ public interface Organisable {
void moveUp();

void moveDown();

/**
* @return full list of all inner MediaInfo objects
*/
List<MediaInfo> getMedia();
}
Expand Up @@ -150,6 +150,12 @@ public void initialize() {
filesChapters.getTabs().remove(chaptersTab);

bookStructure.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
bookStructure.getSelectionModel().getSelectedItems().addListener((ListChangeListener<TreeItem<Organisable>>) c -> {
List<MediaInfo> list = ConverterApplication.getContext().getSelectedMedia();
list.clear();
List<MediaInfo> newList = c.getList().stream().flatMap(item -> item.getValue().getMedia().stream()).collect(Collectors.toList());
list.addAll(newList);
});

chapterColumn.setCellValueFactory(p -> new ReadOnlyObjectWrapper<>(p.getValue().getValue().getTitle()));
detailsColumn.setCellValueFactory(p -> new ReadOnlyObjectWrapper<>(p.getValue().getValue().getDetails()));
Expand Down

0 comments on commit f8dd2e1

Please sign in to comment.