/**
Khalid
*/
package org.sikuli.slides.media;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import org.sikuli.api.audio.DesktopSpeaker;
import org.sikuli.api.audio.Speaker;
import org.sikuli.slides.utils.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Sound {
	private static final Logger logger = (Logger) LoggerFactory.getLogger(Sound.class);
	private String name;
	private String fileName;
	private String relationshipId;
	
	public Sound(){
		
	}
	public Sound (String name, String fileName, String relationshipId){
		this.name=name;
		this.fileName=fileName;
		this.relationshipId=relationshipId;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getFileName() {
		return fileName;
	}
	public void setFileName(String fileName) {
		this.fileName = fileName;
	}
	public String getRelationshipId() {
		return relationshipId;
	}
	public void setRelationshipId(String relationshipId) {
		this.relationshipId = relationshipId;
	}
	
	public void playSound(){
		String slideMediaLocation=Constants.projectDirectory+Constants.MEDIA_DIRECTORY+File.separator+getFileName();
			Speaker speaker = new DesktopSpeaker();
			try {
				speaker.play(new URL("file://"+slideMediaLocation));
			} catch (MalformedURLException e) {
				logger.error("Unknown audio location..");
			}
	}
	public String toString(){
		return "Sound info:\n" +"name:"+name+"\n file name:"+fileName+
				"\n relationshipID="+relationshipId;
	}
	
}

@@ -1094,16 +1094,22 @@
 nd()%7B%0A%09%09
+final 
 String s
@@ -1211,17 +1211,22 @@
 me();%0A%09%09
-%09
+final 
 Speaker 
@@ -1261,17 +1261,97 @@
 ();%0A
+%09%09try %7B%0A%09%09%09new Thread(new Runnable() %7B%0A%09%09%09%09@Override%0A%09%09%09%09public void run() %7B%0A%09%09
 %09%09%09try
- 
 %7B%0A
+%09%09
 %09%09%09%09
@@ -1410,10 +1410,17 @@
 %0A%09%09%09
-%7D 
+%09%09%7D%0A%09%09%09%09%09
 catc
@@ -1445,24 +1445,26 @@
 eption e) %7B%0A
+%09%09
 %09%09%09%09logger.e
@@ -1498,16 +1498,135 @@
 n..%22);%0A%09
+%09%09%09%09%7D%0A%09%09%09%09%7D%0A%09%09%09%7D).start();%0A%09%09%7D %0A%09%09catch (IllegalThreadStateException itse)%7B%0A%09%09%09logger.error(%22Error in playing audio%22);%0A
 %09%09%7D%0A%09%7D%0A%09

add play audio in background