View Javadoc

1   package org.rpi.mplayer;
2   
3   import java.util.Observable;
4   
5   import org.rpi.player.IPlayer;
6   import org.rpi.player.events.EventBase;
7   import org.rpi.player.events.EventUpdateTrackInfo;
8   
9   public class TrackInfo extends Observable {
10  
11  	private boolean bSentUpdate = false;
12  
13  	public TrackInfo() {
14  
15  	}
16  
17  	private String codec = null;
18  	private long bitRate = -99;
19  	private long sampleRate = -99;
20  	private long duration = -99;
21  	private long depth = -99;
22  
23  	/**
24  	 * @return the codec
25  	 */
26  	public String getCodec() {
27  		return codec;
28  	}
29  
30  	/**
31  	 * @param codec
32  	 *            the codec to set
33  	 */
34  	public void setCodec(String codec) {
35  		this.codec = codec;
36  	}
37  
38  	/**
39  	 * @return the bitrate
40  	 */
41  	public long getBitrate() {
42  		return bitRate;
43  	}
44  
45  	/**
46  	 * @param bitrate
47  	 *            the bitrate to set
48  	 */
49  	public void setBitrate(long bitrate) {
50  		this.bitRate = bitrate;
51  	}
52  
53  	/**
54  	 * @return the sample_rate
55  	 */
56  	public long getSampleRate() {
57  		return sampleRate;
58  	}
59  
60  	/**
61  	 * @param sample_rate
62  	 *            the sample_rate to set
63  	 */
64  	public void setSampleRate(long sample_rate) {
65  		this.sampleRate = sample_rate;
66  	}
67  
68  	/**
69  	 * @return the duration
70  	 */
71  	public long getDuration() {
72  		return duration;
73  	}
74  
75  	/**
76  	 * @param duration
77  	 *            the duration to set
78  	 */
79  	public void setDuration(long duration) {
80  		this.duration = duration;
81  	}
82  
83  	public boolean isSet() {
84  		if (bitRate != -99 && sampleRate != -99 && codec != null && duration != -99) {
85  			if (!bSentUpdate) {
86  				EventUpdateTrackInfo ev = new EventUpdateTrackInfo();
87  				ev.setTrackInfo(this);
88  				fireEvent(ev);
89  				bSentUpdate = true;
90  			}
91  			return true;
92  		}
93  		return false;
94  	}
95  
96  	public void setBitDepth(long depth) {
97  		this.depth = depth;
98  	}
99  
100 	public long getBitDepth() {
101 		return depth;
102 	}
103 
104 	public boolean isUpdated() {
105 		return bSentUpdate;
106 	}
107 
108 	public void setUpdated(boolean bUpdated) {
109 		this.bSentUpdate = bUpdated;
110 		if (!bUpdated) {
111 			codec = null;
112 			bitRate = -99;
113 			sampleRate = -99;
114 			duration = -99;
115 			depth = -99;
116 		}
117 	}
118 
119 	private void fireEvent(EventBase ev) {
120 		setChanged();
121 		notifyObservers(ev);
122 	}
123 
124 }