Change time display to show chapter runtime not sentence runtime
This commit is contained in:
@@ -86,7 +86,7 @@ public class BookTreeRenderer extends DefaultTreeCellRenderer {
|
||||
}
|
||||
|
||||
|
||||
JLabel time = new JLabelFixedWidth(75, " " + Utils.secToTime(s.getLength(), "ss.SSS") + " ");
|
||||
JLabel time = new JLabelFixedWidth(75, " " + Utils.secToTime(s.getStartTime(), "mm.ss.SSS") + " ");
|
||||
time.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||
|
||||
ctx.gridx = 0;
|
||||
|
||||
@@ -35,6 +35,7 @@ import javax.sound.sampled.AudioSystem;
|
||||
import javax.sound.sampled.AudioFileFormat;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.TreeNode;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
@@ -819,6 +820,23 @@ public class Sentence extends BookTreeNode implements Cacheable {
|
||||
return pos;
|
||||
}
|
||||
|
||||
public double getStartTime() {
|
||||
double time = 0;
|
||||
DefaultMutableTreeNode prev = getPreviousSibling();
|
||||
while (prev != null) {
|
||||
if (prev instanceof Sentence) {
|
||||
Sentence ps = (Sentence)prev;
|
||||
time += ps.getLength();
|
||||
time += ps.getPostGap() / 1000d;
|
||||
prev = prev.getPreviousSibling();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return time;
|
||||
|
||||
}
|
||||
|
||||
/* Get the length of the sample in seconds */
|
||||
@Override
|
||||
public double getLength() {
|
||||
|
||||
Reference in New Issue
Block a user