Skip to content

Commit

Permalink
set title even if file is reopened
Browse files Browse the repository at this point in the history
rebust against reopening of non-mp4-files (or segements without track boxes)
  • Loading branch information
sannies committed Dec 11, 2014
1 parent 569462b commit 2efd981
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
<dependency>
<groupId>com.googlecode.mp4parser</groupId>
<artifactId>isoparser</artifactId>
<version>1.0.4.2</version>
<version>1.0.4.3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jdesktop.bsaf</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.io.IOException;

public class FileOpenEventHandler implements EventHandler<ActionEvent> {
FileChooser fileChooser = new FileChooser();
Stage stage;
IsoViewerFx isoViewerFx;

Expand All @@ -35,7 +36,7 @@ public FileOpenEventHandler(Stage stage, IsoViewerFx isoViewerFx) {


public void handle(ActionEvent event) {
FileChooser fileChooser = new FileChooser();


//Set extension filter
fileChooser.getExtensionFilters().addAll(
Expand All @@ -48,7 +49,7 @@ public void handle(ActionEvent event) {
stage.setTitle(file.getPath());
try {
isoViewerFx.openFile(file);
stage.setTitle(file.getAbsolutePath());

} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException();
Expand Down
25 changes: 13 additions & 12 deletions src/main/java/com/github/sannies/isoviewer/IsoViewerFx.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,26 @@ public class IsoViewerFx extends Application {

public void openFile(File f) throws IOException {
IsoFile isoFile = new IsoFile(f.getAbsolutePath());
stage.setTitle(f.getAbsolutePath());
userPrefs.put("openedFile", f.getAbsolutePath());
boxesOrTracksTabPane.getTabs().clear();
boxesOrTracksTabPane.getTabs().add(createBoxAndDetailTab(isoFile));

List<TrackBox> trackBoxes = isoFile.getMovieBox().getBoxes(TrackBox.class);
if (isoFile.getMovieBox() != null) {
List<TrackBox> trackBoxes = isoFile.getMovieBox().getBoxes(TrackBox.class);


for (TrackBox trackBox : trackBoxes) {
SchemeTypeBox schm = Path.getPath(trackBox, "mdia[0]/minf[0]/stbl[0]/stsd[0]/enc.[0]/sinf[0]/schm[0]");
if (schm != null && (schm.getSchemeType().equals("cenc") || schm.getSchemeType().equals("cbc1"))) {
boxesOrTracksTabPane.getTabs().add(
createTrackTab(new CencMp4TrackImplImpl(f.getName() + "[" + trackBox.getTrackHeaderBox().getTrackId() + "]", trackBox)));
} else {
boxesOrTracksTabPane.getTabs().add(
createTrackTab(new Mp4TrackImpl(f.getName() + "[" + trackBox.getTrackHeaderBox().getTrackId() + "]", trackBox)));
for (TrackBox trackBox : trackBoxes) {
SchemeTypeBox schm = Path.getPath(trackBox, "mdia[0]/minf[0]/stbl[0]/stsd[0]/enc.[0]/sinf[0]/schm[0]");
if (schm != null && (schm.getSchemeType().equals("cenc") || schm.getSchemeType().equals("cbc1"))) {
boxesOrTracksTabPane.getTabs().add(
createTrackTab(new CencMp4TrackImplImpl(f.getName() + "[" + trackBox.getTrackHeaderBox().getTrackId() + "]", trackBox)));
} else {
boxesOrTracksTabPane.getTabs().add(
createTrackTab(new Mp4TrackImpl(f.getName() + "[" + trackBox.getTrackHeaderBox().getTrackId() + "]", trackBox)));
}
}
}


}
}

@Override
Expand Down

0 comments on commit 2efd981

Please sign in to comment.