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

import java.io.File;
import java.io.IOException;
import javax.sound.sampled.UnsupportedAudioFileException;
import net.jsoundsystem.JSound;
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();
		try {
			JSound sound = new JSound(slideMediaLocation);
			sound.play();
		}
		catch (UnsupportedAudioFileException e) {
			logger.error("Error in playing the audio file: Unsupported audio file format");
		} catch (IOException e) {
			logger.error("Error in playing the audio file: Failed I/O operation.");
		}
	}
	public String toString(){
		return "Sound info:\n" +"name:"+name+"\n file name:"+fileName+
				"\n relationshipID="+relationshipId;
	}
	
}

@@ -1069,16 +1069,50 @@
 ound()%7B%0A
+%09%09logger.info(%22Playing audio..%22);%0A
 %09%09String
@@ -1130,17 +1130,19 @@
 Location
-=
+ = 
 Constant
@@ -1159,17 +1159,19 @@
 irectory
-+
+ + 
 Constant
@@ -1187,17 +1187,19 @@
 IRECTORY
-+
+ + 
 File.sep
@@ -1204,17 +1204,19 @@
 eparator
-+
+ + 
 getFileN
@@ -1227,17 +1227,16 @@
 );%0A%09%09try
- 
 %7B%0A%09%09%09JSo
@@ -1430,17 +1430,19 @@
 t%22);%0A%09%09%7D
- 
+%0A%09%09
 catch (I
@@ -1536,19 +1536,21 @@
 %22);%0A%09%09%7D%0A
-
 %09%7D%0A
+%09%0A
 %09public 

refactor Sound class