| 1 | /* |
|---|
| 2 | * To change this license header, choose License Headers in Project Properties. |
|---|
| 3 | * To change this template file, choose Tools | Templates |
|---|
| 4 | * and open the template in the editor. |
|---|
| 5 | */ |
|---|
| 6 | package scriptbuilder.structures.events; |
|---|
| 7 | |
|---|
| 8 | import scriptbuilder.structures.ELEMENT; |
|---|
| 9 | import scriptbuilder.structures.I_XML_Writable; |
|---|
| 10 | import scriptbuilder.structures.ScriptEvent; |
|---|
| 11 | import scriptbuilder.structures.XMLWriter; |
|---|
| 12 | |
|---|
| 13 | /** |
|---|
| 14 | * Data model for an audio event. Audio events have a filepath leading to an |
|---|
| 15 | * audio file to be played, and a length in seconds of that file. |
|---|
| 16 | * |
|---|
| 17 | * @author Bryan McGuffin |
|---|
| 18 | */ |
|---|
| 19 | public class AudioEvent extends ScriptEvent implements I_XML_Writable |
|---|
| 20 | { |
|---|
| 21 | |
|---|
| 22 | /** |
|---|
| 23 | * Constructor. |
|---|
| 24 | */ |
|---|
| 25 | public AudioEvent() |
|---|
| 26 | { |
|---|
| 27 | super(ScriptEventType.AUDIO_EVENT); |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | /** |
|---|
| 31 | * Constructor with ID |
|---|
| 32 | * @param id AudioEvent ID |
|---|
| 33 | */ |
|---|
| 34 | public AudioEvent(String id) |
|---|
| 35 | { |
|---|
| 36 | super(ScriptEventType.AUDIO_EVENT); |
|---|
| 37 | this.id = id; |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | /** |
|---|
| 41 | * Length of the audio to be played, in seconds. |
|---|
| 42 | */ |
|---|
| 43 | public Integer audioLength = 0; |
|---|
| 44 | |
|---|
| 45 | /** |
|---|
| 46 | * File path for the audio file. |
|---|
| 47 | */ |
|---|
| 48 | public String audioPath = ""; |
|---|
| 49 | |
|---|
| 50 | /** |
|---|
| 51 | * id represents the audio file name that corresponds with the event |
|---|
| 52 | */ |
|---|
| 53 | public String id = ""; |
|---|
| 54 | |
|---|
| 55 | /** |
|---|
| 56 | * sets the audio path relative to the running directory. |
|---|
| 57 | * @param f filename |
|---|
| 58 | */ |
|---|
| 59 | |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | public void setAudioFilePathRelative(String f) |
|---|
| 63 | { |
|---|
| 64 | audioPath = "audio/" + f + ".mp3"; |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | public void setAudioFilePathRelative() |
|---|
| 68 | { |
|---|
| 69 | audioPath = "audio/" + id + ".mp3"; |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | @Override |
|---|
| 73 | public String toXML() |
|---|
| 74 | { |
|---|
| 75 | return XMLWriter.emptyTag(ELEMENT.AUDIO.tag + " Length=\"" + audioLength + "\" Path=\"" + audioPath + "\""); |
|---|
| 76 | } |
|---|
| 77 | } |
|---|