summaryrefslogtreecommitdiff
path: root/cmpcj
diff options
context:
space:
mode:
Diffstat (limited to 'cmpcj')
-rw-r--r--cmpcj/.classpath3
-rw-r--r--cmpcj/lib/gson-2.2.2.jarbin0 -> 189285 bytes
-rw-r--r--cmpcj/lib/jackson-all-1.9.2.jarbin1107436 -> 0 bytes
-rw-r--r--cmpcj/res/images/folder_black.pngbin117733 -> 0 bytes
-rw-r--r--cmpcj/res/images/folder_black_dvd.pngbin116838 -> 0 bytes
-rw-r--r--cmpcj/res/images/folder_black_i_dvd.pngbin128700 -> 0 bytes
-rw-r--r--cmpcj/res/images/folder_black_i_movies.pngbin133715 -> 0 bytes
-rw-r--r--cmpcj/res/images/folder_black_i_vdr.pngbin140435 -> 0 bytes
-rw-r--r--cmpcj/res/images/folder_black_i_vdr_old.pngbin181800 -> 0 bytes
-rw-r--r--cmpcj/res/images/folder_black_library.pngbin121207 -> 0 bytes
-rw-r--r--cmpcj/res/images/folder_black_movies.pngbin125320 -> 0 bytes
-rw-r--r--cmpcj/res/images/folder_black_music.pngbin121853 -> 0 bytes
-rw-r--r--cmpcj/res/images/folder_black_photos.pngbin129249 -> 0 bytes
-rw-r--r--cmpcj/res/images/folder_black_playlist.pngbin121207 -> 0 bytes
-rw-r--r--cmpcj/res/images/folder_black_vdr.pngbin128692 -> 0 bytes
-rw-r--r--cmpcj/res/images/folder_black_vdr_old.pngbin172383 -> 0 bytes
-rw-r--r--cmpcj/res/images/sr_default.pngbin0 -> 114212 bytes
-rw-r--r--cmpcj/res/images/sr_dvd.pngbin0 -> 119043 bytes
-rw-r--r--cmpcj/res/images/sr_dvd_i.pngbin0 -> 134812 bytes
-rw-r--r--cmpcj/res/images/sr_lvdr.pngbin0 -> 174142 bytes
-rw-r--r--cmpcj/res/images/sr_lvdr_i.pngbin0 -> 185903 bytes
-rw-r--r--cmpcj/res/images/sr_movies.pngbin0 -> 122199 bytes
-rw-r--r--cmpcj/res/images/sr_movies_i.pngbin0 -> 138608 bytes
-rw-r--r--cmpcj/res/images/sr_music.pngbin0 -> 117609 bytes
-rw-r--r--cmpcj/res/images/sr_photos.pngbin0 -> 124129 bytes
-rw-r--r--cmpcj/res/images/sr_playlist.pngbin0 -> 116457 bytes
-rw-r--r--cmpcj/res/images/sr_vdr.pngbin0 -> 130356 bytes
-rw-r--r--cmpcj/res/images/sr_vdr_i.pngbin0 -> 145850 bytes
-rw-r--r--cmpcj/res/images/sradefault.pngbin0 -> 131251 bytes
-rw-r--r--cmpcj/res/images/sradvd.pngbin0 -> 136534 bytes
-rw-r--r--cmpcj/res/images/sradvd_i.pngbin0 -> 152638 bytes
-rw-r--r--cmpcj/res/images/sralvdr.pngbin0 -> 190151 bytes
-rw-r--r--cmpcj/res/images/sralvdr_i.pngbin0 -> 201594 bytes
-rw-r--r--cmpcj/res/images/sramovies.pngbin0 -> 138966 bytes
-rw-r--r--cmpcj/res/images/sramovies_i.pngbin0 -> 156017 bytes
-rw-r--r--cmpcj/res/images/sramusic.pngbin0 -> 134757 bytes
-rw-r--r--cmpcj/res/images/sraphotos.pngbin0 -> 140488 bytes
-rw-r--r--cmpcj/res/images/sraplaylist.pngbin0 -> 132791 bytes
-rw-r--r--cmpcj/res/images/sravdr.pngbin0 -> 146699 bytes
-rw-r--r--cmpcj/res/images/sravdr_i.pngbin0 -> 162536 bytes
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/app/SRMediaPlayer.java37
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/domain/MediaType.java34
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/util/MediaListLoader.java36
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/util/MediaTypeSelect.java39
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/util/MedialistParser.java173
45 files changed, 263 insertions, 59 deletions
diff --git a/cmpcj/.classpath b/cmpcj/.classpath
index ae6697e..b28f98d 100644
--- a/cmpcj/.classpath
+++ b/cmpcj/.classpath
@@ -4,6 +4,7 @@
<classpathentry kind="src" path="res"/>
<classpathentry kind="lib" path="lib/glazedlists_java15.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="lib" path="lib/jackson-all-1.9.2.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
+ <classpathentry kind="lib" path="lib/gson-2.2.2.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/cmpcj/lib/gson-2.2.2.jar b/cmpcj/lib/gson-2.2.2.jar
new file mode 100644
index 0000000..f2108e0
--- /dev/null
+++ b/cmpcj/lib/gson-2.2.2.jar
Binary files differ
diff --git a/cmpcj/lib/jackson-all-1.9.2.jar b/cmpcj/lib/jackson-all-1.9.2.jar
deleted file mode 100644
index f1d8c3d..0000000
--- a/cmpcj/lib/jackson-all-1.9.2.jar
+++ /dev/null
Binary files differ
diff --git a/cmpcj/res/images/folder_black.png b/cmpcj/res/images/folder_black.png
deleted file mode 100644
index 01b5b20..0000000
--- a/cmpcj/res/images/folder_black.png
+++ /dev/null
Binary files differ
diff --git a/cmpcj/res/images/folder_black_dvd.png b/cmpcj/res/images/folder_black_dvd.png
deleted file mode 100644
index 26c72c2..0000000
--- a/cmpcj/res/images/folder_black_dvd.png
+++ /dev/null
Binary files differ
diff --git a/cmpcj/res/images/folder_black_i_dvd.png b/cmpcj/res/images/folder_black_i_dvd.png
deleted file mode 100644
index 2b4294c..0000000
--- a/cmpcj/res/images/folder_black_i_dvd.png
+++ /dev/null
Binary files differ
diff --git a/cmpcj/res/images/folder_black_i_movies.png b/cmpcj/res/images/folder_black_i_movies.png
deleted file mode 100644
index e5ed555..0000000
--- a/cmpcj/res/images/folder_black_i_movies.png
+++ /dev/null
Binary files differ
diff --git a/cmpcj/res/images/folder_black_i_vdr.png b/cmpcj/res/images/folder_black_i_vdr.png
deleted file mode 100644
index 129b733..0000000
--- a/cmpcj/res/images/folder_black_i_vdr.png
+++ /dev/null
Binary files differ
diff --git a/cmpcj/res/images/folder_black_i_vdr_old.png b/cmpcj/res/images/folder_black_i_vdr_old.png
deleted file mode 100644
index 4cb2584..0000000
--- a/cmpcj/res/images/folder_black_i_vdr_old.png
+++ /dev/null
Binary files differ
diff --git a/cmpcj/res/images/folder_black_library.png b/cmpcj/res/images/folder_black_library.png
deleted file mode 100644
index 6e1cc81..0000000
--- a/cmpcj/res/images/folder_black_library.png
+++ /dev/null
Binary files differ
diff --git a/cmpcj/res/images/folder_black_movies.png b/cmpcj/res/images/folder_black_movies.png
deleted file mode 100644
index 34c46f3..0000000
--- a/cmpcj/res/images/folder_black_movies.png
+++ /dev/null
Binary files differ
diff --git a/cmpcj/res/images/folder_black_music.png b/cmpcj/res/images/folder_black_music.png
deleted file mode 100644
index e534703..0000000
--- a/cmpcj/res/images/folder_black_music.png
+++ /dev/null
Binary files differ
diff --git a/cmpcj/res/images/folder_black_photos.png b/cmpcj/res/images/folder_black_photos.png
deleted file mode 100644
index 59f80a4..0000000
--- a/cmpcj/res/images/folder_black_photos.png
+++ /dev/null
Binary files differ
diff --git a/cmpcj/res/images/folder_black_playlist.png b/cmpcj/res/images/folder_black_playlist.png
deleted file mode 100644
index 6e1cc81..0000000
--- a/cmpcj/res/images/folder_black_playlist.png
+++ /dev/null
Binary files differ
diff --git a/cmpcj/res/images/folder_black_vdr.png b/cmpcj/res/images/folder_black_vdr.png
deleted file mode 100644
index 17fcbb9..0000000
--- a/cmpcj/res/images/folder_black_vdr.png
+++ /dev/null
Binary files differ
diff --git a/cmpcj/res/images/folder_black_vdr_old.png b/cmpcj/res/images/folder_black_vdr_old.png
deleted file mode 100644
index b56f5f7..0000000
--- a/cmpcj/res/images/folder_black_vdr_old.png
+++ /dev/null
Binary files differ
diff --git a/cmpcj/res/images/sr_default.png b/cmpcj/res/images/sr_default.png
new file mode 100644
index 0000000..8628dfe
--- /dev/null
+++ b/cmpcj/res/images/sr_default.png
Binary files differ
diff --git a/cmpcj/res/images/sr_dvd.png b/cmpcj/res/images/sr_dvd.png
new file mode 100644
index 0000000..899b0e3
--- /dev/null
+++ b/cmpcj/res/images/sr_dvd.png
Binary files differ
diff --git a/cmpcj/res/images/sr_dvd_i.png b/cmpcj/res/images/sr_dvd_i.png
new file mode 100644
index 0000000..18a7571
--- /dev/null
+++ b/cmpcj/res/images/sr_dvd_i.png
Binary files differ
diff --git a/cmpcj/res/images/sr_lvdr.png b/cmpcj/res/images/sr_lvdr.png
new file mode 100644
index 0000000..1b90956
--- /dev/null
+++ b/cmpcj/res/images/sr_lvdr.png
Binary files differ
diff --git a/cmpcj/res/images/sr_lvdr_i.png b/cmpcj/res/images/sr_lvdr_i.png
new file mode 100644
index 0000000..31a475e
--- /dev/null
+++ b/cmpcj/res/images/sr_lvdr_i.png
Binary files differ
diff --git a/cmpcj/res/images/sr_movies.png b/cmpcj/res/images/sr_movies.png
new file mode 100644
index 0000000..794a5fa
--- /dev/null
+++ b/cmpcj/res/images/sr_movies.png
Binary files differ
diff --git a/cmpcj/res/images/sr_movies_i.png b/cmpcj/res/images/sr_movies_i.png
new file mode 100644
index 0000000..efe3e3a
--- /dev/null
+++ b/cmpcj/res/images/sr_movies_i.png
Binary files differ
diff --git a/cmpcj/res/images/sr_music.png b/cmpcj/res/images/sr_music.png
new file mode 100644
index 0000000..cacaa0c
--- /dev/null
+++ b/cmpcj/res/images/sr_music.png
Binary files differ
diff --git a/cmpcj/res/images/sr_photos.png b/cmpcj/res/images/sr_photos.png
new file mode 100644
index 0000000..8493512
--- /dev/null
+++ b/cmpcj/res/images/sr_photos.png
Binary files differ
diff --git a/cmpcj/res/images/sr_playlist.png b/cmpcj/res/images/sr_playlist.png
new file mode 100644
index 0000000..41ca388
--- /dev/null
+++ b/cmpcj/res/images/sr_playlist.png
Binary files differ
diff --git a/cmpcj/res/images/sr_vdr.png b/cmpcj/res/images/sr_vdr.png
new file mode 100644
index 0000000..d750edf
--- /dev/null
+++ b/cmpcj/res/images/sr_vdr.png
Binary files differ
diff --git a/cmpcj/res/images/sr_vdr_i.png b/cmpcj/res/images/sr_vdr_i.png
new file mode 100644
index 0000000..a02a741
--- /dev/null
+++ b/cmpcj/res/images/sr_vdr_i.png
Binary files differ
diff --git a/cmpcj/res/images/sradefault.png b/cmpcj/res/images/sradefault.png
new file mode 100644
index 0000000..fa5ae3d
--- /dev/null
+++ b/cmpcj/res/images/sradefault.png
Binary files differ
diff --git a/cmpcj/res/images/sradvd.png b/cmpcj/res/images/sradvd.png
new file mode 100644
index 0000000..fd66ad5
--- /dev/null
+++ b/cmpcj/res/images/sradvd.png
Binary files differ
diff --git a/cmpcj/res/images/sradvd_i.png b/cmpcj/res/images/sradvd_i.png
new file mode 100644
index 0000000..b7fc014
--- /dev/null
+++ b/cmpcj/res/images/sradvd_i.png
Binary files differ
diff --git a/cmpcj/res/images/sralvdr.png b/cmpcj/res/images/sralvdr.png
new file mode 100644
index 0000000..5677308
--- /dev/null
+++ b/cmpcj/res/images/sralvdr.png
Binary files differ
diff --git a/cmpcj/res/images/sralvdr_i.png b/cmpcj/res/images/sralvdr_i.png
new file mode 100644
index 0000000..c6f1725
--- /dev/null
+++ b/cmpcj/res/images/sralvdr_i.png
Binary files differ
diff --git a/cmpcj/res/images/sramovies.png b/cmpcj/res/images/sramovies.png
new file mode 100644
index 0000000..b74967a
--- /dev/null
+++ b/cmpcj/res/images/sramovies.png
Binary files differ
diff --git a/cmpcj/res/images/sramovies_i.png b/cmpcj/res/images/sramovies_i.png
new file mode 100644
index 0000000..85c08e7
--- /dev/null
+++ b/cmpcj/res/images/sramovies_i.png
Binary files differ
diff --git a/cmpcj/res/images/sramusic.png b/cmpcj/res/images/sramusic.png
new file mode 100644
index 0000000..9a0ceb9
--- /dev/null
+++ b/cmpcj/res/images/sramusic.png
Binary files differ
diff --git a/cmpcj/res/images/sraphotos.png b/cmpcj/res/images/sraphotos.png
new file mode 100644
index 0000000..47192f0
--- /dev/null
+++ b/cmpcj/res/images/sraphotos.png
Binary files differ
diff --git a/cmpcj/res/images/sraplaylist.png b/cmpcj/res/images/sraplaylist.png
new file mode 100644
index 0000000..f1dc30b
--- /dev/null
+++ b/cmpcj/res/images/sraplaylist.png
Binary files differ
diff --git a/cmpcj/res/images/sravdr.png b/cmpcj/res/images/sravdr.png
new file mode 100644
index 0000000..2f75626
--- /dev/null
+++ b/cmpcj/res/images/sravdr.png
Binary files differ
diff --git a/cmpcj/res/images/sravdr_i.png b/cmpcj/res/images/sravdr_i.png
new file mode 100644
index 0000000..24c0e18
--- /dev/null
+++ b/cmpcj/res/images/sravdr_i.png
Binary files differ
diff --git a/cmpcj/src/de/schwarzrot/cmpc/app/SRMediaPlayer.java b/cmpcj/src/de/schwarzrot/cmpc/app/SRMediaPlayer.java
index 73f6204..0448549 100644
--- a/cmpcj/src/de/schwarzrot/cmpc/app/SRMediaPlayer.java
+++ b/cmpcj/src/de/schwarzrot/cmpc/app/SRMediaPlayer.java
@@ -1,25 +1,25 @@
/**
* ======================== legal notice ======================
*
- * File: SRMediaPlayer.java
- * Created:
- * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
- * Project: cmpc - a java frontend (client) part of compound media player
- * uses external players to play the media
+ * File: SRMediaPlayer.java Created: Author: <a
+ * href="mailto:geronimo013@gmx.de">Geronimo</a> Project: cmpc - a java frontend
+ * (client) part of compound media player uses external players to play the
+ * media
*
* CMP - compound media player
*
- * is a client/server mediaplayer intended to play any media from any workstation
- * without the need to export or mount shares. cmps is an easy to use backend
- * with a (ready to use) HTML-interface. Additionally the backend supports
- * authentication via HTTP-digest authorization.
- * cmpc is a client with vdr-like osd-menues.
+ * is a client/server mediaplayer intended to play any media from any
+ * workstation without the need to export or mount shares. cmps is an easy to
+ * use backend with a (ready to use) HTML-interface. Additionally the backend
+ * supports authentication via HTTP-digest authorization. cmpc is a client with
+ * vdr-like osd-menues.
*
- * Copyright (c) 2012 Reinhard Mantey, some rights reserved!
- * published under Creative Commons by-sa
- * For details see http://creativecommons.org/licenses/by-sa/3.0/
+ * Copyright (c) 2012 Reinhard Mantey, some rights reserved! published under
+ * Creative Commons by-sa For details see
+ * http://creativecommons.org/licenses/by-sa/3.0/
*
- * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp
+ * The cmp project's homepage is at
+ * http://projects.vdr-developer.org/projects/cmp
*
* --------------------------------------------------------------
*/
@@ -159,6 +159,7 @@ public class SRMediaPlayer implements IMediaPlayer {
public static void main(final String[] args) {
+ appInfo();
javax.swing.SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
@@ -169,6 +170,14 @@ public class SRMediaPlayer implements IMediaPlayer {
});
}
+
+ protected static void appInfo() {
+ System.err.println("cmpcj - the java frontend of CMP (compound media player)");
+ System.err.println(" serves to browse a medialist from remote systems and to start a player");
+ System.err.println(" for selected media.");
+ System.err.println(" (c) 2012 - Reinhard Mantey - some rights reserved.");
+ System.err.println(" CMP is published as open source under Creative Commons by-sa");
+ }
private boolean debug = false;
private JFrame mainFrame;
private Config config;
diff --git a/cmpcj/src/de/schwarzrot/cmpc/domain/MediaType.java b/cmpcj/src/de/schwarzrot/cmpc/domain/MediaType.java
index c336329..57f320f 100644
--- a/cmpcj/src/de/schwarzrot/cmpc/domain/MediaType.java
+++ b/cmpcj/src/de/schwarzrot/cmpc/domain/MediaType.java
@@ -1,25 +1,25 @@
/**
* ======================== legal notice ======================
*
- * File: MediaType.java
- * Created:
- * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
- * Project: cmpc - a java frontend (client) part of compound media player
- * uses external players to play the media
+ * File: MediaType.java Created: Author: <a
+ * href="mailto:geronimo013@gmx.de">Geronimo</a> Project: cmpc - a java frontend
+ * (client) part of compound media player uses external players to play the
+ * media
*
* CMP - compound media player
*
- * is a client/server mediaplayer intended to play any media from any workstation
- * without the need to export or mount shares. cmps is an easy to use backend
- * with a (ready to use) HTML-interface. Additionally the backend supports
- * authentication via HTTP-digest authorization.
- * cmpc is a client with vdr-like osd-menues.
+ * is a client/server mediaplayer intended to play any media from any
+ * workstation without the need to export or mount shares. cmps is an easy to
+ * use backend with a (ready to use) HTML-interface. Additionally the backend
+ * supports authentication via HTTP-digest authorization. cmpc is a client with
+ * vdr-like osd-menues.
*
- * Copyright (c) 2012 Reinhard Mantey, some rights reserved!
- * published under Creative Commons by-sa
- * For details see http://creativecommons.org/licenses/by-sa/3.0/
+ * Copyright (c) 2012 Reinhard Mantey, some rights reserved! published under
+ * Creative Commons by-sa For details see
+ * http://creativecommons.org/licenses/by-sa/3.0/
*
- * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp
+ * The cmp project's homepage is at
+ * http://projects.vdr-developer.org/projects/cmp
*
* --------------------------------------------------------------
*/
@@ -32,7 +32,7 @@ public class MediaType {
}
- public int getStart() {
+ public long getStart() {
return start;
}
@@ -42,10 +42,10 @@ public class MediaType {
}
- public void setStart(int start) {
+ public void setStart(long start) {
this.start = start;
}
private String name;
- private int start;
+ private long start;
}
diff --git a/cmpcj/src/de/schwarzrot/cmpc/util/MediaListLoader.java b/cmpcj/src/de/schwarzrot/cmpc/util/MediaListLoader.java
index b37834c..983fdd3 100644
--- a/cmpcj/src/de/schwarzrot/cmpc/util/MediaListLoader.java
+++ b/cmpcj/src/de/schwarzrot/cmpc/util/MediaListLoader.java
@@ -1,25 +1,25 @@
/**
* ======================== legal notice ======================
*
- * File: MediaListLoader.java
- * Created:
- * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
- * Project: cmpc - a java frontend (client) part of compound media player
- * uses external players to play the media
+ * File: MediaListLoader.java Created: Author: <a
+ * href="mailto:geronimo013@gmx.de">Geronimo</a> Project: cmpc - a java frontend
+ * (client) part of compound media player uses external players to play the
+ * media
*
* CMP - compound media player
*
- * is a client/server mediaplayer intended to play any media from any workstation
- * without the need to export or mount shares. cmps is an easy to use backend
- * with a (ready to use) HTML-interface. Additionally the backend supports
- * authentication via HTTP-digest authorization.
- * cmpc is a client with vdr-like osd-menues.
+ * is a client/server mediaplayer intended to play any media from any
+ * workstation without the need to export or mount shares. cmps is an easy to
+ * use backend with a (ready to use) HTML-interface. Additionally the backend
+ * supports authentication via HTTP-digest authorization. cmpc is a client with
+ * vdr-like osd-menues.
*
- * Copyright (c) 2012 Reinhard Mantey, some rights reserved!
- * published under Creative Commons by-sa
- * For details see http://creativecommons.org/licenses/by-sa/3.0/
+ * Copyright (c) 2012 Reinhard Mantey, some rights reserved! published under
+ * Creative Commons by-sa For details see
+ * http://creativecommons.org/licenses/by-sa/3.0/
*
- * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp
+ * The cmp project's homepage is at
+ * http://projects.vdr-developer.org/projects/cmp
*
* --------------------------------------------------------------
*/
@@ -30,7 +30,6 @@ import java.net.ConnectException;
import java.net.URL;
import java.net.URLConnection;
import java.util.Date;
-import org.codehaus.jackson.map.ObjectMapper;
import ca.odell.glazedlists.BasicEventList;
import ca.odell.glazedlists.EventList;
import de.schwarzrot.cmpc.domain.Media;
@@ -64,7 +63,7 @@ public class MediaListLoader implements Runnable {
start = new Date();
request = new URL("http", hostName, port, "/?format=json");
URLConnection conn = request.openConnection();
- final PlayList firstPlaylist = jsonOM.readValue(conn.getInputStream(), PlayList.class);
+ final PlayList firstPlaylist = jsonParser.parseListChunk(conn.getInputStream());
mediaPool.getReadWriteLock().writeLock().lock();
for (Media m : firstPlaylist.getResults()) {
@@ -85,7 +84,7 @@ public class MediaListLoader implements Runnable {
uri = String.format("/?start=%d&limit=%d&format=json", n, 100);
request = new URL("http", hostName, port, uri);
conn = request.openConnection();
- next = jsonOM.readValue(conn.getInputStream(), PlayList.class);
+ next = jsonParser.parseListChunk(conn.getInputStream());
mediaPool.getReadWriteLock().writeLock().lock();
for (Media m : next.getResults()) {
mediaPool.add(m);
@@ -96,6 +95,7 @@ public class MediaListLoader implements Runnable {
}
} catch (Throwable t) {
System.out.println("Oups, media list contains now #" + mediaPool.size() + " entries.");
+ System.err.println("Error on chunk #" + n);
t.printStackTrace();
} finally {
try {
@@ -119,6 +119,6 @@ public class MediaListLoader implements Runnable {
private String hostName;
private int port;
- private ObjectMapper jsonOM = new ObjectMapper();
+ private MedialistParser jsonParser = new MedialistParser();
private EventList<Media> mediaPool = new BasicEventList<Media>();
}
diff --git a/cmpcj/src/de/schwarzrot/cmpc/util/MediaTypeSelect.java b/cmpcj/src/de/schwarzrot/cmpc/util/MediaTypeSelect.java
index 24cd506..bde865a 100644
--- a/cmpcj/src/de/schwarzrot/cmpc/util/MediaTypeSelect.java
+++ b/cmpcj/src/de/schwarzrot/cmpc/util/MediaTypeSelect.java
@@ -60,14 +60,17 @@ public class MediaTypeSelect extends AbstractMatcherEditor<Media> implements Lis
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
boolean cellHasFocus) {
+ ImageIcon icon = null;
+
if (isSelected) {
setBackground(list.getSelectionBackground());
setForeground(list.getSelectionForeground());
+ icon = selImages[((Media.SupportedMediaType) value).ordinal()];
} else {
setBackground(list.getBackground());
setForeground(list.getForeground());
+ icon = stdImages[((Media.SupportedMediaType) value).ordinal()];
}
- ImageIcon icon = images[((Media.SupportedMediaType) value).ordinal()];
setSize(110, 110);
setHorizontalAlignment(JLabel.CENTER);
@@ -86,21 +89,35 @@ public class MediaTypeSelect extends AbstractMatcherEditor<Media> implements Lis
ClassLoader cl = getClass().getClassLoader();
URL url;
- images = new ImageIcon[iconFiles.length];
+ stdImages = new ImageIcon[iconFiles.length];
for (int i = 0; i < iconFiles.length; ++i) {
try {
url = cl.getResource(iconFiles[i]);
img = ImageIO.read(url);
- images[i] = new ImageIcon(img.getScaledInstance(110, 110, Image.SCALE_SMOOTH));
+ stdImages[i] = new ImageIcon(img.getScaledInstance(110, 110, Image.SCALE_SMOOTH));
} catch (Throwable t) {
System.err.println("failed to read image from " + iconFiles[i]);
t.printStackTrace();
}
}
+
+ selImages = new ImageIcon[activeIconFiles.length];
+ for (int i = 0; i < activeIconFiles.length; ++i) {
+ try {
+ url = cl.getResource(activeIconFiles[i]);
+
+ img = ImageIO.read(url);
+ selImages[i] = new ImageIcon(img.getScaledInstance(110, 110, Image.SCALE_SMOOTH));
+ } catch (Throwable t) {
+ System.err.println("failed to read image from " + activeIconFiles[i]);
+ t.printStackTrace();
+ }
+ }
}
- ImageIcon[] images;
+ ImageIcon[] stdImages;
+ ImageIcon[] selImages;
}
@@ -139,11 +156,15 @@ public class MediaTypeSelect extends AbstractMatcherEditor<Media> implements Lis
private EventList<Media.SupportedMediaType> selectedTypes;
private JList mediaTypeJList;
private static final String[] iconFiles;
+ private static final String[] activeIconFiles;
static {
- iconFiles = new String[] { "images/folder_black.png", "images/folder_black_music.png",
- "images/folder_black_movies.png", "images/folder_black_i_movies.png", "images/folder_black_dvd.png",
- "images/folder_black_i_dvd.png", "images/folder_black_vdr_old.png",
- "images/folder_black_i_vdr_old.png", "images/folder_black_vdr.png", "images/folder_black_i_vdr.png",
- "images/folder_black_photos.png", "images/folder_black.png" };
+ iconFiles = new String[] { "images/sr_default.png", "images/sr_music.png", "images/sr_movies.png",
+ "images/sr_movies_i.png", "images/sr_dvd.png", "images/sr_dvd_i.png", "images/sr_lvdr.png",
+ "images/sr_lvdr_i.png", "images/sr_vdr.png", "images/sr_vdr_i.png", "images/sr_photos.png",
+ "images/sr_default.png" };
+ activeIconFiles = new String[] { "images/sradefault.png", "images/sramusic.png", "images/sramovies.png",
+ "images/sramovies_i.png", "images/sradvd.png", "images/sradvd_i.png", "images/sralvdr.png",
+ "images/sralvdr_i.png", "images/sravdr.png", "images/sravdr_i.png", "images/sraphotos.png",
+ "images/sradefault.png" };
}
}
diff --git a/cmpcj/src/de/schwarzrot/cmpc/util/MedialistParser.java b/cmpcj/src/de/schwarzrot/cmpc/util/MedialistParser.java
new file mode 100644
index 0000000..8f69af0
--- /dev/null
+++ b/cmpcj/src/de/schwarzrot/cmpc/util/MedialistParser.java
@@ -0,0 +1,173 @@
+package de.schwarzrot.cmpc.util;
+
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Test;
+import com.google.gson.stream.JsonReader;
+import de.schwarzrot.cmpc.domain.Media;
+import de.schwarzrot.cmpc.domain.MediaType;
+import de.schwarzrot.cmpc.domain.PlayList;
+
+
+public class MedialistParser {
+ public PlayList parseListChunk(InputStream is) {
+ JsonReader reader = null;
+ PlayList rv = null;
+
+ try {
+ reader = new JsonReader(new InputStreamReader(is, "UTF-8"));
+
+ rv = readPlayList(reader);
+ } catch (Throwable t) {
+ t.printStackTrace();
+ } finally {
+ try {
+ reader.close();
+ } catch (Throwable t) {
+ }
+ }
+ return rv;
+ }
+
+
+ @Test
+ public void testJSonParsing() {
+ FileInputStream fis = null;
+
+ try {
+ fis = new FileInputStream(new File("test.json"));
+ parseListChunk(fis);
+ fis.close();
+ fis = null;
+ } catch (Throwable t) {
+ t.printStackTrace();
+ } finally {
+ if (fis != null) {
+ try {
+ fis.close();
+ } catch (Throwable t) {
+ }
+ }
+ }
+ }
+
+
+ protected Media readMedia(JsonReader reader) {
+ Media rv = new Media();
+
+ try {
+ reader.beginObject();
+ while (reader.hasNext()) {
+ String name = reader.nextName();
+
+ if ("name".equals(name)) {
+ rv.setName(reader.nextString());
+ } else if ("type".equals(name)) {
+ rv.setType(reader.nextInt());
+ } else if ("format".equals(name)) {
+ rv.setFormat(reader.nextString());
+ } else if ("width".equals(name)) {
+ rv.setWidth(reader.nextInt());
+ } else if ("height".equals(name)) {
+ rv.setHeight(reader.nextInt());
+ } else if ("path".equals(name)) {
+ rv.setPath(reader.nextString());
+ } else {
+ reader.skipValue();
+ }
+ }
+ reader.endObject();
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ return rv;
+ }
+
+
+ protected List<Media> readMediaArray(JsonReader reader) {
+ List<Media> rv = new ArrayList<Media>();
+
+ try {
+ reader.beginArray();
+ while (reader.hasNext()) {
+ rv.add(readMedia(reader));
+ }
+ reader.endArray();
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ return rv;
+ }
+
+
+ protected MediaType readMediaType(JsonReader reader) {
+ MediaType rv = new MediaType();
+
+ try {
+ reader.beginObject();
+ while (reader.hasNext()) {
+ String name = reader.nextName();
+
+ if ("name".equals(name)) {
+ rv.setName(reader.nextString());
+ } else if ("start".equals(name)) {
+ rv.setStart(reader.nextLong());
+ } else {
+ reader.skipValue();
+ }
+ }
+ reader.endObject();
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ return rv;
+ }
+
+
+ protected PlayList readPlayList(JsonReader reader) {
+ PlayList rv = new PlayList();
+
+ try {
+ reader.beginObject();
+ while (reader.hasNext()) {
+ String name = reader.nextName();
+
+ if ("total".equals(name)) {
+ rv.setTotal(reader.nextLong());
+ } else if ("types".equals(name)) {
+ rv.setTypes(readTypeArray(reader));
+ } else if ("results".equals(name)) {
+ rv.setResults(readMediaArray(reader));
+ } else {
+ reader.skipValue();
+ }
+ }
+ reader.endObject();
+ } catch (Throwable t) {
+ t.printStackTrace();
+ rv = null;
+ }
+ return rv;
+ }
+
+
+ protected List<MediaType> readTypeArray(JsonReader reader) {
+ List<MediaType> rv = new ArrayList<MediaType>();
+
+ try {
+ reader.beginArray();
+ while (reader.hasNext()) {
+ rv.add(readMediaType(reader));
+ }
+ reader.endArray();
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ return rv;
+ }
+}