1 package org.readium.r2_streamer.model.publication.SMIL;
3 import org.w3c.dom.Element;
5 import java.io.Serializable;
6 import java.util.ArrayList;
10 * Created by gautam chibde on 23/5/17.
13 public class MediaOverlayNode implements Serializable {
14 private static final long serialVersionUID = 7329984331545950872L;
18 public List<String> role;
19 public List<MediaOverlayNode> children;
21 public MediaOverlayNode() {
22 this.children = new ArrayList<>();
23 this.role = new ArrayList<>();
27 public String toString() {
28 return "MediaOverlayNode{" +
29 "text='" + text + '\'' +
30 ", audio='" + audio + '\'' +
32 ", children=" + children +
37 * Generate Clip from current instance object
39 * @return The generated Clip.
41 public Clip clip() throws IndexOutOfBoundsException {
42 Clip newClip = new Clip();
44 // Retrieve the audioString (containing timers + audiofile url), then
46 newClip.relativeUrl = this.audio.split("#")[0];
47 String times = this.audio.split("#")[1];
48 return parseTimer(times, newClip);
52 * Parse the time String to fill clip.
54 * @param times The time string ("t=S.MS,S.MS") as created in {@link SMILParser#parseAudio(Element)}
55 * @param clip The Clip instance where to fill the parsed data.
56 * @return returns clips with start, end and duration
58 private Clip parseTimer(String times, Clip clip) throws IndexOutOfBoundsException {
59 // Remove "t=" prefix from times string.
60 times = times.substring(2, times.length());
61 // Parse start and end times.
62 Double start = Double.parseDouble(times.split(",")[0]);
63 Double end = Double.parseDouble(times.split(",")[1]);
66 clip.duration = end - start;