Changeset 108
- Timestamp:
- 03/02/07 20:14:46 (2 years ago)
- Files:
-
- dmp/trunk/XmLRpcBridgeServer/BridgeXmlRpcServer.cs (modified) (1 diff)
- dmp/trunk/gwt-windows-1.3.3/src/DMP/DMPXmlRpcClient.java (modified) (3 diffs)
- dmp/trunk/gwt-windows-1.3.3/src/DMP/client/DMPWebsite.java (modified) (5 diffs)
- dmp/trunk/gwt-windows-1.3.3/src/DMP/client/MusicServ.java (modified) (1 diff)
- dmp/trunk/gwt-windows-1.3.3/src/DMP/client/MusicServAsync.java (modified) (1 diff)
- dmp/trunk/gwt-windows-1.3.3/src/DMP/client/SongTable.java (modified) (8 diffs)
- dmp/trunk/gwt-windows-1.3.3/src/DMP/server/MusicServImpl.java (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
dmp/trunk/XmLRpcBridgeServer/BridgeXmlRpcServer.cs
r107 r108 152 152 while(reader.Read()) 153 153 { 154 Object[] values = new Object[reader.FieldCount]; 155 reader.GetValues(values); 156 ArrayList song = new ArrayList(); 157 foreach(Object obj in values) 154 Hashtable song = new Hashtable(); 155 for (int i = 0; i < reader.FieldCount; i++) 158 156 { 159 song.Add(obj.ToString()); 157 String columnName = reader.GetName(i); 158 song.Add(columnName, reader.GetValue(i).ToString()); 160 159 } 161 160 collection.Add(song); dmp/trunk/gwt-windows-1.3.3/src/DMP/DMPXmlRpcClient.java
r107 r108 10 10 import java.net.URL; 11 11 import java.util.Vector; 12 import java.util.HashMap; 12 13 import java.util.ArrayList; 13 14 … … 87 88 88 89 /** 89 * Gets a Vector< Vector<String>> of the songs in the collection.90 * @return a Vector< Vector<String>>90 * Gets a Vector<HashMap> of the songs in the collection. 91 * @return a Vector<HashMap> 91 92 */ 92 93 public Vector getSongsFromCollection() … … 99 100 } 100 101 catch (XmlRpcException e) { 101 // TODO Auto-generated catch block102 102 e.printStackTrace(); 103 103 } 104 104 105 // formats the returned response into a Vector<Vector<String>> 106 Vector<Vector<String>> response = new Vector<Vector<String>>(); 107 Vector<String> songVector = new Vector<String>(); 105 Vector<HashMap> collection = new Vector<HashMap>(); 108 106 if (resp != null) { 109 107 for (Object o : resp) { 110 Object[] song = (Object[]) o; 111 songVector = new Vector<String>(); 112 for (Object obj : song) { 113 songVector.add((String) obj); 114 } 115 response.add(songVector); 108 HashMap song = (HashMap) o; 109 collection.add(song); 116 110 } 117 111 } 118 119 return response; 112 return collection; 120 113 } 121 114 } dmp/trunk/gwt-windows-1.3.3/src/DMP/client/DMPWebsite.java
r99 r108 7 7 import com.google.gwt.user.client.Timer; 8 8 import java.util.Vector; 9 import java.util.HashMap; 9 10 10 11 /** … … 30 31 } 31 32 Widget parent = w.getParent(); 32 Vectorsong = collection.getSong(clickText);33 HashMap song = collection.getSong(clickText); 33 34 if(song != null && parent == collection) 34 35 { … … 67 68 getSongsFromCollection(); 68 69 69 Vector tags = new Vector(); 70 tags.add("title"); 71 tags.add("artist"); 72 tags.add("comment"); 73 for(int i = 5; i > 0; i--) 74 { 75 tags.add("test" + i); 76 } 77 collection.setTagList(tags); 70 Vector collectionTags = new Vector(); 71 collectionTags.add("id"); 72 collectionTags.add("Title"); 73 collectionTags.add("Artist"); 74 collectionTags.add("Size"); 75 collectionTags.add("Duration"); 76 collection.setTagList(collectionTags); 78 77 collection.setTitle("Song Collection"); 78 79 79 playing.setTitle("Now Playing"); 80 playing.setTagList( tags);80 playing.setTagList(collectionTags); //just use the same tags as the collection for now 81 81 82 82 FlowPanel topPanel = new FlowPanel(); … … 130 130 } 131 131 }; 132 testPlay.schedule(60000);132 //testPlay.schedule(60000); 133 133 } 134 134 … … 171 171 }); 172 172 } 173 174 private FlexTable makeSongTable(int[] songs)175 {176 FlexTable songTable = new FlexTable();177 songTable.setTitle("Collection");178 songTable.setCellPadding(5);179 songTable.setCellSpacing(3);180 songTable.setBorderWidth(2);181 songTable.setText(0,0,"Song");182 songTable.setText(0, 1, "Album");183 songTable.setText(0, 2, "Artist");184 return songTable;185 }186 173 } dmp/trunk/gwt-windows-1.3.3/src/DMP/client/MusicServ.java
r78 r108 2 2 3 3 import java.util.Vector; 4 import java.util.HashMap; 4 5 import com.google.gwt.user.client.rpc.RemoteService; 5 6 6 7 public interface MusicServ extends RemoteService { 7 8 public Vector getSongsFromCollection(); 8 public void addSongToPlaying( Vectorsong);9 public void removeSongFromPlaying( Vectorsong);9 public void addSongToPlaying(HashMap song); 10 public void removeSongFromPlaying(HashMap song); 10 11 public String getNextSong(); 11 12 } dmp/trunk/gwt-windows-1.3.3/src/DMP/client/MusicServAsync.java
r78 r108 2 2 3 3 import com.google.gwt.user.client.rpc.*; 4 import java.util. Vector;4 import java.util.HashMap; 5 5 6 6 public interface MusicServAsync { 7 7 public void getSongsFromCollection(AsyncCallback callback); 8 public void addSongToPlaying( Vectorsong, AsyncCallback callback);9 public void removeSongFromPlaying( Vectorsong, AsyncCallback callback);8 public void addSongToPlaying(HashMap song, AsyncCallback callback); 9 public void removeSongFromPlaying(HashMap song, AsyncCallback callback); 10 10 public void getNextSong(AsyncCallback callback); 11 11 } dmp/trunk/gwt-windows-1.3.3/src/DMP/client/SongTable.java
r78 r108 8 8 import java.util.Vector; 9 9 import java.util.Iterator; 10 import java.util.HashMap; 10 11 11 12 /** … … 70 71 * @param song song to add 71 72 */ 72 public void addSong( Vectorsong)73 public void addSong(HashMap song) 73 74 { 74 75 if(!songList.contains(song)) … … 83 84 * @param song song to remove 84 85 */ 85 public void removeSong( Vectorsong)86 public void removeSong(HashMap song) 86 87 { 87 88 if(songList.contains(song)) … … 99 100 { 100 101 Iterator it = songs.iterator(); 101 Vectorsong = null;102 HashMap song = null; 102 103 while(it.hasNext()) 103 104 { 104 song = ( Vector) it.next();105 song = (HashMap) it.next(); 105 106 if(!songList.contains(song)) 106 107 { … … 112 113 113 114 /** 115 * Broken, will fix later. 114 116 * Sorts the songs in this table by the specified tag 115 117 * @param tag tag for the songs to be sorted by … … 160 162 } 161 163 162 /**163 * Emptys and refills the table using the song and tag lists.164 */165 164 protected void refillTable() 166 165 { 167 166 emptyTable(); 168 int i = 0; 169 int j = 0; 170 while(i < songList.size()) 171 { 172 j = 0; 173 Vector song = (Vector) songList.get(i); 174 while(j < song.size() && j < tagList.size()) 175 { 176 if(j == 0) 177 { 178 String songTitle = (String) song.get(j); 167 for(int row = 0; row < songList.size(); row++) 168 { 169 HashMap song = (HashMap) songList.get(row); 170 for(int column = 0; column < tagList.size(); column++) 171 { 172 if(column == 0) 173 { 174 String songTitle = (String) song.get(((String)tagList.get(column)).toLowerCase()); 179 175 Button songButton = new Button(songTitle); 180 176 songButton.setTitle(songTitle); 181 177 songButton.addClickListener(listener); 182 this.setWidget( i, j, songButton);178 this.setWidget(row, column, songButton); 183 179 } 184 180 else 185 181 { 186 setText(i,j,(String)song.get(j)); 187 } 188 j++; 189 } 190 i++; 182 setText(row, column, (String) song.get(((String)tagList.get(column)).toLowerCase())); 183 } 184 } 191 185 } 192 186 // sets up the top label bar 193 187 insertRow(0); 194 i = 0;188 int i = 0; 195 189 while(i < tagList.size()) 196 190 { … … 204 198 } 205 199 200 /** Old method, kept for reference. 201 * Emptys and refills the table using the song and tag lists. 202 */ 203 protected void refillTable2() 204 { 205 emptyTable(); 206 int i = 0; 207 int j = 0; 208 while(i < songList.size()) 209 { 210 j = 0; 211 Vector song = (Vector) songList.get(i); 212 while(j < song.size() && j < tagList.size()) 213 { 214 if(j == 0) 215 { 216 String songTitle = (String) song.get(j); 217 Button songButton = new Button(songTitle); 218 songButton.setTitle(songTitle); 219 songButton.addClickListener(listener); 220 this.setWidget(i, j, songButton); 221 } 222 else 223 { 224 setText(i,j,(String)song.get(j)); 225 } 226 j++; 227 } 228 i++; 229 } 230 // sets up the top label bar 231 insertRow(0); 232 i = 0; 233 while(i < tagList.size()) 234 { 235 String tagTitle = (String) tagList.get(i); 236 Button tagButton = new Button(tagTitle); 237 tagButton.setTitle("Sort by " + tagTitle); 238 tagButton.addClickListener(listener); 239 this.setWidget(0, i, tagButton); 240 i++; 241 } 242 } 243 206 244 /** 207 245 * Gets the song in this table with the specified string identifier. … … 210 248 * @return the song Vector of the found song or null if the song is not found 211 249 */ 212 public VectorgetSong(String songIdentifier)250 public HashMap getSong(String songIdentifier) 213 251 { 214 252 Iterator it = songList.iterator(); 215 Vector song = new Vector();253 HashMap song = new HashMap(); 216 254 while(it.hasNext()) 217 255 { 218 song = ( Vector) it.next();219 if(song.contains (songIdentifier))256 song = (HashMap) it.next(); 257 if(song.containsValue(songIdentifier)) 220 258 { 221 259 return song; dmp/trunk/gwt-windows-1.3.3/src/DMP/server/MusicServImpl.java
r107 r108 25 25 26 26 private static final long serialVersionUID = 02; 27 private LinkedList< Vector> playing;27 private LinkedList<HashMap> playing; 28 28 private DMPXmlRpcClient client; 29 private HashMap< Vector,File> flashFileHandles = new HashMap<Vector,File>();29 private HashMap<HashMap,File> flashFileHandles = new HashMap<HashMap,File>(); 30 30 31 31 // testing method … … 41 41 public MusicServImpl() 42 42 { 43 playing = new LinkedList< Vector>();43 playing = new LinkedList<HashMap>(); 44 44 client = new DMPXmlRpcClient(); 45 45 } … … 48 48 public String getNextSong() 49 49 { 50 Vectorsong = playing.poll();50 HashMap song = playing.poll(); 51 51 File songHandle = flashFileHandles.get(song); 52 52 return songHandle.getPath(); 53 53 } 54 54 55 public void addSongToPlaying( Vectorsong)55 public void addSongToPlaying(HashMap song) 56 56 { 57 57 playing.add(song); … … 59 59 } 60 60 61 public void removeSongFromPlaying( Vectorsong)61 public void removeSongFromPlaying(HashMap song) 62 62 { 63 63 if(playing.contains(song)) … … 107 107 * @return the path of the flash file created 108 108 */ 109 public void makeFlash( Vectorsong)110 { 111 Integer songID = Integer.parseInt((song.get( 0).toString()));109 public void makeFlash(HashMap song) 110 { 111 Integer songID = Integer.parseInt((song.get("id").toString())); 112 112 byte[] musicBytes = client.getSong(songID.intValue()); 113 113 if(musicBytes == null) … … 143 143 } 144 144 // use temp files to create flash movie 145 createFlashMovie(tempMusicFile.getPath(),tempFlashFile.getPath()); 146 tempMusicFile.delete(); 145 boolean created = createFlashMovie(tempMusicFile.getPath(),tempFlashFile.getPath()); 146 System.out.println("" + tempFlashFile.getPath() + " is " + created); 147 tempMusicFile.delete(); //always delete the temp music file 148 if(!created) //if the flash isn't created, end 149 { 150 return; 151 } 147 152 tempFlashFile.deleteOnExit(); 148 153 flashFileHandles.put(song, tempFlashFile); … … 177 182 } 178 183 //System.out.println(makeFlash(musicBytes)); 179 int breakpoint = 0;180 184 } 181 185 … … 209 213 return false; 210 214 } 211 212 int samplesPerBlock = soundGenerator.getSampleRate() / framesPerSecond; 213 int numberOfBlocks = soundGenerator.getSamplesPerChannel() / samplesPerBlock; 215 216 int samplesPerBlock; 217 int numberOfBlocks; 218 try { 219 samplesPerBlock = soundGenerator.getSampleRate() / framesPerSecond; 220 numberOfBlocks = soundGenerator.getSamplesPerChannel() / samplesPerBlock; 221 } catch (ArithmeticException e1) { 222 e1.printStackTrace(); 223 return false; 224 } 214 225 215 226 musicMov.add(soundGenerator.streamHeader(samplesPerBlock));
