Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: jreceiver/server/util/playlist/PlaylistWriterPLS.java


1   /* $Header: /cvsroot/jreceiver/jreceiver/src/jreceiver/server/util/playlist/PlaylistWriterPLS.java,v 1.6 2003/05/04 19:47:22 reedesau Exp $ */
2   
3   package jreceiver.server.util.playlist;
4   
5   import java.io.Writer;
6   import java.io.IOException;
7   
8   import jreceiver.common.rec.source.Source;
9   import jreceiver.common.rec.source.Tune;
10  import jreceiver.common.rec.source.Playlist;
11  
12  /**
13   * Write a PLS playlist
14   * <p>
15   * [playlist]
16   * File1=Blues\Muddy Waters - Rollin Stone.mp3
17   * Title1=Various Artists - Muddy Waters - Rollin' Stone
18   * Length1=188
19   * File2=Classical\Carmina Burana - O Fortuna.mp3
20   * Title2=Carmina Burana - O Fortuna
21   * Length2=154
22   * File3=Classical\Champagne Polka - Johann Strauss.mp3
23   * Title3=Champagne Polka - Johann Strauss
24   * Length3=153
25   * File4=Classical\Immortal Beloved, Fur Elise.mp3
26   * Title4=Unknown Artist - Fur Elise
27   * Length4=172
28   * NumberOfEntries=4
29   * Version=2
30   *
31   * @author Reed Esau
32   * @version $Revision: 1.6 $ $Date: 2003/05/04 19:47:22 $
33   */
34  
35  public class PlaylistWriterPLS extends PlaylistWriter {
36  
37      /** ctor */
38      protected PlaylistWriterPLS(Writer in) {
39          super(in);
40      }
41  
42      /** */
43      protected void writeHeader()  throws IOException {
44          write("[playlist]\r\n");
45      }
46  
47      /** */
48      protected void writeEntry(int entry_no, Source source)  throws IOException {
49          write("File");
50          write( Integer.toString(entry_no) );
51          write("=");
52          write(source.getContentSystemId());
53          write("\r\n");
54  
55          write("Title");
56          write( Integer.toString(entry_no) );
57          write("=");
58          write(source.getTitle());
59          write("\r\n");
60  
61          if (source.getIsTune()) {
62              Tune tune = (Tune)source;
63              write("Length");
64              write( Integer.toString(entry_no) );
65              write("=");
66              write( Integer.toString(tune.getDuration()) );
67              write("\r\n");
68          }
69          else if (source.getIsPlaylist()) {
70              Playlist playlist = (Playlist)source;
71              write("Length");
72              write( Integer.toString(entry_no) );
73              write("=");
74              write( Integer.toString(playlist.getDuration()) );
75              write("\r\n");
76          }
77      }
78  
79      /** */
80      protected void writeFooter(int entry_count)  throws IOException {
81          write("NumberOfEntries=");
82          write( Integer.toString(entry_count) );
83          write("\r\n");
84          write("Version=2\r\n");
85      }
86  }
87  /*
88  JRECEIVER MODIFIED BSD LICENSE
89  
90  Copyright (c) 2001-2002, Reed Esau (reed.esau@pobox.com) All rights reserved.
91  
92  Redistribution and use in source and binary forms, with or without
93  modification, are permitted provided that the following conditions are
94  met:
95  
96  Redistributions of source code must retain the above copyright notice,
97  this list of conditions and the following disclaimer.
98  
99  Redistributions in binary form must reproduce the above copyright notice,
100 this list of conditions and the following disclaimer in the documentation
101 and/or other materials provided with the distribution.
102 
103 Neither the name of the JReceiver Project
104 (http://jreceiver.sourceforge.net) nor the names of its contributors may
105 be used to endorse or promote products derived from this software without
106 specific prior written permission.
107 
108 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
109 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
110 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
111 PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
112 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
113 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
114 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
115 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
116 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
117 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
118 POSSIBILITY OF SUCH DAMAGE.
119 */
120