Source code: jreceiver/server/util/playlist/PlaylistWriterASX.java
1 /* $Header: /cvsroot/jreceiver/jreceiver/src/jreceiver/server/util/playlist/PlaylistWriterASX.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
10 /**
11 * Write a ASX playlist
12 * <p>
13 * <ASX version="3.0">
14 * <ABSTRACT>This is a sample asx file used as playlist</ABSTRACT>
15 * <TITLE>Windows Media Playlist Demo</TITLE>
16 * <AUTHOR>Reed Esau</AUTHOR>
17 * <COPYRIGHT>2002 Reed Esau</COPYRIGHT>
18 * <ENTRY>
19 * <REF href="File1.asf" />
20 * <ABSTRACT>Link to a local file on the same folder</ABSTRACT>
21 * </ENTRY>
22 * <ENTRY>
23 * <REF href="mms://media.phm.lu/File2.asf" />
24 * <ABSTRACT>a file streamed from a media server on the network</ABSTRACT>
25 * </ENTRY>
26 * <ENTRY>
27 * <REF href="File3.mp3" />
28 * <ABSTRACT>ASX can support any file type supported by WMP</ABSTRACT>
29 * </ENTRY>
30 * <ENTRY>
31 * <REF href="File4.avi" />
32 * <ABSTRACT>you can even mix audio files and video files in the same ASX</ABSTRACT>
33 * </ENTRY>
34 *
35 * </ASX>
36 *
37 * @author Reed Esau
38 * @version $Revision: 1.6 $ $Date: 2003/05/04 19:47:22 $
39 */
40
41 public class PlaylistWriterASX extends PlaylistWriter {
42
43 /** ctor */
44 protected PlaylistWriterASX(Writer in) {
45 super(in);
46 }
47
48 /** */
49 protected void writeHeader() throws IOException {
50 //write("<?xml version='1.0'?>\r\n"); //TODO: specify an encoding
51 write("<ASX version=\"3.0\">\r\n");
52 }
53
54 /** */
55 protected void writeEntry(int entry_no, Source source) throws IOException {
56 write("<ENTRY>");
57 write("\t<REF href='");
58 write(source.getContentSystemId()); //TODO: htmlescape all &, >, <, etc.
59 write("'/>\r\n");
60 write("\t<ABSTRACT>");
61 write(source.getTitle());
62 write("</ABSTRACT>\r\n");
63 write("</ENTRY>\r\n");
64 }
65
66 /** */
67 protected void writeFooter(int entry_count) throws IOException {
68 write("</ASX>\r\n"); //pseudo-xml
69 }
70 }
71 /*
72 JRECEIVER MODIFIED BSD LICENSE
73
74 Copyright (c) 2002, Reed Esau (reed.esau@pobox.com) All rights reserved.
75
76 Redistribution and use in source and binary forms, with or without
77 modification, are permitted provided that the following conditions are
78 met:
79
80 Redistributions of source code must retain the above copyright notice,
81 this list of conditions and the following disclaimer.
82
83 Redistributions in binary form must reproduce the above copyright notice,
84 this list of conditions and the following disclaimer in the documentation
85 and/or other materials provided with the distribution.
86
87 Neither the name of the JReceiver Project
88 (http://jreceiver.sourceforge.net) nor the names of its contributors may
89 be used to endorse or promote products derived from this software without
90 specific prior written permission.
91
92 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
93 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
94 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
95 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
96 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
97 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
98 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
99 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
100 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
101 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
102 POSSIBILITY OF SUCH DAMAGE.
103 */
104