<commit_before>package com.chj.gwt.client.soundmanager2;

import com.google.gwt.core.client.JavaScriptObject;

/**
 * SMSound objects are created everytime SoundManager creates a sound. You can
 * retrieve SMSound objects from SoundManager by calling getSoundById and
 * passing in the id that was passed to SoundManager to create the sound.
 * SMSound is used to collect data on the sound loaded up by SoundManager. To
 * use callbacks on a particular sound use SoundOptions callbacks when creating
 * the sound initially.
 * 
 * @author JMILLER
 * @author RCALORAS
 * 
 */
public class SMSound {

	private JavaScriptObject obj;

	SMSound(JavaScriptObject obj) {
		this.obj = obj;
	}

	public String getSID() {
		return sID();
	}

	private native String sID()/*-{
	 return this.@com.chj.gwt.client.soundmanager2.SMSound::obj.sID;
	 }-*/;

	public String getURL() {
		return url();
	}

	private native String url()/*-{
	 return this.@com.chj.gwt.client.soundmanager2.SMSound::obj.url;
	 }-*/;

	/**
	 * Need to abstract out again to make ID3 an actual object
	 * 
	 * @return ID3
	 */
	public ID3 getID3() {
		return new ID3(id3());
	}

	private native JavaScriptObject id3()/*-{
	 return this.@com.chj.gwt.client.soundmanager2.SMSound::obj.id3;
	 }-*/;

	public int getBytesLoaded() {
		return bytesLoaded();
	}

	private native int bytesLoaded()/*-{
	 return this.@com.chj.gwt.client.soundmanager2.SMSound::obj.bytesLoaded;
	 }-*/;

	public int getBytesTotal() {
		return bytesTotal();
	}

	private native int bytesTotal()/*-{
	 return this.@com.chj.gwt.client.soundmanager2.SMSound::obj.bytesTotal;
	 }-*/;

	public int getPosition() {
		try {
			return position() / 1000;
		} catch (Exception e) {
			e.printStackTrace();
			return -1;
		}
	}

	private native int position()/*-{
	 return this.@com.chj.gwt.client.soundmanager2.SMSound::obj.position;
	 }-*/;

	public int getDuration() {
		try {
			return duration() / 1000;
		} catch (Exception e) {
			e.printStackTrace();
			return -1;
		}
	}

	private native int duration()/*-{
	 return this.@com.<EMAIL>.gwt.client.soundmanager2.SMSound::obj.duration;
	 }-*/;

	public int getDurationEstimate() {
		try {
			int estimate = durationEstimate();
			if(estimate == -1){
				return estimate;
			}
			else{
				return durationEstimate() / 1000;
			}
		} catch (Exception e) {
			e.printStackTrace();
			return -1;
		}
	}
	
	/*
	 * Use check due to this error:
	 * Something other than an int was returned from JSNI method 
	 * '@com.chj.gwt.client.soundmanager2.SMSound::durationEstimate()': 
	 * JS value of type null, expected int.
	 */
	private native int durationEstimate()/*-{
	 var test = this.@com.chj.gwt.client.soundmanager2.SMSound::obj.durationEstimate;
	 if(test != null){
	 	return test;
	 }
	 else{
	 	return -1;
	 	}
	 <commit_msg>Fixed getBytesLoaded and getBytesTotal exception<commit_after>package com.chj.gwt.client.soundmanager2;

import com.google.gwt.core.client.JavaScriptObject;

/**
 * SMSound objects are created everytime SoundManager creates a sound. You can
 * retrieve SMSound objects from SoundManager by calling getSoundById and
 * passing in the id that was passed to SoundManager to create the sound.
 * SMSound is used to collect data on the sound loaded up by SoundManager. To
 * use callbacks on a particular sound use SoundOptions callbacks when creating
 * the sound initially.
 * 
 * @author JMILLER
 * @author RCALORAS
 * 
 */
public class SMSound {

	private JavaScriptObject obj;

	SMSound(JavaScriptObject obj) {
		this.obj = obj;
	}

	public String getSID() {
		return sID();
	}

	private native String sID()/*-{
	 return this.@com.chj.gwt.client.soundmanager2.SMSound::obj.sID;
	 }-*/;

	public String getURL() {
		return url();
	}

	private native String url()/*-{
	 return this.@com.chj.gwt.client.soundmanager2.SMSound::obj.url;
	 }-*/;

	/**
	 * Need to abstract out again to make ID3 an actual object
	 * 
	 * @return ID3
	 */
	public ID3 getID3() {
		return new ID3(id3());
	}

	private native JavaScriptObject id3()/*-{
	 return this.@com.chj.gwt.client.soundmanager2.SMSound::obj.id3;
	 }-*/;

	/**
	 * The number of bytes currently received while loading a sound.
	 * 
	 * @return bytes currently received, -1 on error
	 */
	public int getBytesLoaded() {
		return bytesLoaded();
	}

	private native int bytesLoaded()/*-{
	 var test = this.@com.chj.gwt.client.soundmanager2.SMSound::obj.bytesLoaded;
	 if(test != null){
	 	return test;
	 }	
	 else{
	 	return -1;
	 	}
	 
	 }-*/;
	
	/**
	 * The total number of bytes to be downloaded, while loading a sound.
	 * 
	 * @return total number of bytes, -1 on error.
	 */
	public int getBytesTotal() {
		return bytesTotal();
	}

	private native int bytesTotal()/*-{
	  var test = this.@com.chj.gwt.client.soundmanager2.SMSound::obj.bytesTotal;
	 if(test != null){
	 	return test;
	 }
	 else{
	 	return -1;
	 	}
	 
	 }-*/;

	public int getPosition() {
		try {
			return position() / 1000;
		} catch (Exception e) {
			e.printStackTrace();
			return -1;
		}
	}

	private native int position()/*-{
	 return this.@com.chj.gwt.client.soundmanager2.SMSound::obj.position;
	 }-*/;

	public int getDuration() {
		try {
			return duration() / 1000;
		} catch (Exception e) {
			e.printStackTrace();
			return -1;
		}
	}

	private native int duration()/*-{
	 return this.@com.chj.gwt.client.soundmanager2.SMSound::obj.duration;
	 }-*/;

	/**
	 * The estimated duration of the sound, specified in milliseconds.
	 * 
	 * @return estimated duration in milliseconds, -1 on error.
	 */
	public int getDurationEstimate() {
		try {
			int estimate = durationEstimate();
			if(estimate == -1){
				return estimate;
			}
			else{
				return durationEstimate() / 1000;
			}
		} catch (Exception e) {
			e.printStackTrace();
			return -1;
		}
	}
	
	/*
	 * Use check due to this error:
	 * Something other than an int was returned from JSNI method 
	 * '@com.chj.gwt.client.soundmanager2.SMSound::durationEstimate()': 
	 * JS value of type null, expected int.
	 */
	private native int durationEstimate()/*-{
	 var test = this.@com.chj.gwt.client.soundmanager2.SMSound::obj.durationEstimate;
	 if(test != null){
	 	return test;
	 }
	 else{
	 	return -1;
	 	}
	 
{'fraction_non_alphanumeric': 0.13059641183125908, 'fraction_numerical': 0.01212219169225796, 'mean_word_length': 3.1782579338284944, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 15, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5934239', 'n_tokens_mistral': 2314, 'n_tokens_neox': 2005, 'n_words': 564}