📄 librarymgr.java
字号:
package no.auc.one.portableplayer.librarymanager;
import java.util.Vector;
//import no.auc.one.portableplayer.communication.*;
import no.auc.one.portableplayer.communication.mediaserver.*;
import no.auc.one.portableplayer.communication.mediarenderer.*;
/**
* This class holds the information about the UPnP Media servers and UPnP Media renderers
* discovered as well as the local media.
*/
public class LibraryMgr {
private static LibraryMgr ref = null;
Vector servers = null;
Vector renderers = null;
Vector localTracks = null;
MediaContent[] remoteContent = null;
private Vector browsepath = null;
private LibraryMgr() {
servers = new Vector();
renderers = new Vector();
localTracks = new Vector();
remoteContent = null;
browsepath = new Vector();
}
/**
* @return Returns a reference to the object of the UI class
*/
public static LibraryMgr getInstance() {
if (ref == null) {
ref = new LibraryMgr();
}
return ref;
}
/**
* XXX Or should it be setContainer instead??!? XXX
* XXX NB! Should be updated to reflect changes in CDS etc.
*
* @param cds Reference to the Server you are browsing
* @param parentID The objectID you want to browse in the specific server
*/
public void getContainer(ContentDirectoryService cds, String parentID) {
try {
remoteContent = cds.browseDirectChildren(
parentID).getMediaContent();
/*
// Add all tracks in mc to remote track list
for(int i = 0; i < mc.length; i++) {
Class c = mc[i].getClass();
if (mc[i] instanceof TrackInformation) {
tracks.addElement((TrackInformation)mc[i]);
} else if (mc[i] instanceof ContentContainer) {
containers.addElement((ContentContainer)mc[i]);
} else {
System.out.println(
"LibraryMgr::getContainer - Strange, not a track and not a container." +
"What is it?! " + mc[i]);
}
}
TrackInformation[] ti = new TrackInformation[tracks.size()];
for(int i = 0; i < tracks.size(); i++) {
ti[i] = (TrackInformation)tracks.elementAt(i);
}
// XXX Should also do something with the content containers discovered
// Just output for now..
ContentContainer[] cc = new ContentContainer[containers.size()];
for(int i = 0; i < containers.size(); i++) {
cc[i] = (ContentContainer)containers.elementAt(i);
System.out.println("Content container: " + cc[i].getName());
}
*/
} catch (java.io.IOException ioe) {
ioe.printStackTrace();
}
}
/**
* @param objectID The objectID of the element you are browsing
*/
public void addBrowsePathElement(int objectID) {
browsepath.addElement(new Integer(objectID));
}
/**
* Deletes the last element in the menupath Vector
*/
public void deleteBrowsePathElement() {
browsepath.removeElementAt(browsepath.size()-1);
}
/**
* Deletes all elements in the menupath Vector
*/
public void flushBrowsePath() {
browsepath.removeAllElements();
}
/**
* @param index The index to the browsepath element you want to get
* @return The objectID to the specific browsepath element
*/
public int getBrowsePathElement(int index) {
Integer i = (Integer) browsepath.elementAt(index);
return i.intValue();
}
/**
* @return Number of elements in the browsepath Vector
*/
public int getBrowsePathSize() {
return browsepath.size();
}
/**
* @param index The index to the TrackInformation element you want to get
* @return The TrackInformation element at the specific index
*/
public MediaContent getRemoteContentElement(int index) {
return remoteContent[index];
}
/**
* @return Number of elements in the remoteTrackList Vector
*/
public int getRemoteContentSize() {
return (remoteContent.length - 1); // XXX Or not -1???
}
/**
* @param renderer A reference to the AVRendererInformation object you want to add to the AVRenderer List
*/
public void addAvRendererInformation(MediaRenderer mr) {
renderers.addElement(mr);
}
/**
* @param index The index to the AvRendererInformation element you want to get
* @return The AvRendererInformation element at the specific index
*/
public MediaRenderer getAvRendererInformation(int index) {
return (MediaRenderer)renderers.elementAt(index);
}
/**
* @return The number of AVRenderers on the list
*/
public int getNumberOfMediaRenderers() {
return renderers.size();
}
/**
* @param server A reference to the MediaServer object you want to add to the Servers list
*/
public void addServer(MediaServer server) {
servers.addElement(server);
}
/**
* @param index The index to the MediaServer element you want to get
* @return The MediaServer element at the specific index
*/
public MediaServer getServer(int index) {
return (MediaServer)servers.elementAt(index);
}
/**
* @return The number of UPnP servers on the list
*/
public int getNumberOfServer() {
return servers.size();
}
/**
* @param track A reference to the TrackInformation object you want to add to the localTracks list
*/
public void addLocalTrack(TrackInformation track) {
localTracks.addElement(track);
}
/**
* @param index The index to the TrackInformation element you want to get
* @return The TrackInformation element at the specific index
*/
public TrackInformation getLocalTrack(int index) {
return (TrackInformation) localTracks.elementAt(index);
}
/**
* @return The number of registered local tracks (localTracks Vector)
*/
public int getNumberOfLocalTracks() {
return localTracks.size();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -