本文整理汇总了Java中org.fourthline.cling.support.model.DIDLObject类的典型用法代码示例。如果您正苦于以下问题:Java DIDLObject类的具体用法?Java DIDLObject怎么用?Java DIDLObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DIDLObject类属于org.fourthline.cling.support.model包,在下文中一共展示了DIDLObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createItem
import org.fourthline.cling.support.model.DIDLObject; //导入依赖的package包/类
public Item createItem(MediaFile song) throws Exception {
MediaFile parent = getMediaFileService().getParentOf(song);
MusicTrack item = new MusicTrack();
item.setId(String.valueOf(song.getId()));
item.setParentID(String.valueOf(parent.getId()));
item.setTitle(song.getTitle());
item.setAlbum(song.getAlbumName());
if (song.getArtist() != null) {
item.setArtists(getDispatcher().getAlbumProcessor().getAlbumArtists(song.getArtist()));
}
Integer year = song.getYear();
if (year != null) {
item.setDate(year + "-01-01");
}
item.setOriginalTrackNumber(song.getTrackNumber());
if (song.getGenre() != null) {
item.setGenres(new String[]{song.getGenre()});
}
item.setResources(Arrays.asList(getDispatcher().createResourceForSong(song)));
item.setDescription(song.getComment());
item.addProperty(new DIDLObject.Property.UPNP.ALBUM_ART_URI(getDispatcher().getAlbumProcessor().getAlbumArtURI(parent.getId())));
return item;
}
示例2: createTestContentDirectory
import org.fourthline.cling.support.model.DIDLObject; //导入依赖的package包/类
/**
*
*/
private void createTestContentDirectory() {
StorageFolder rootContainer = new StorageFolder("0", "-1", "root",
"yaacc", 2, 907000L);
rootContainer.setClazz(new DIDLObject.Class("object.container"));
rootContainer.setRestricted(true);
addContent(rootContainer.getId(), rootContainer);
List<MusicTrack> musicTracks = createMusicTracks("1");
MusicAlbum musicAlbum = new MusicAlbum("1", rootContainer, "Music",
null, musicTracks.size(), musicTracks);
musicAlbum.setClazz(new DIDLObject.Class("object.container"));
musicAlbum.setRestricted(true);
rootContainer.addContainer(musicAlbum);
addContent(musicAlbum.getId(), musicAlbum);
List<Photo> photos = createPhotos("2");
PhotoAlbum photoAlbum = new PhotoAlbum("2", rootContainer, "Photos",
null, photos.size(), photos);
photoAlbum.setClazz(new DIDLObject.Class("object.container"));
photoAlbum.setRestricted(true);
rootContainer.addContainer(photoAlbum);
addContent(photoAlbum.getId(), photoAlbum);
}
示例3: toItemList
import org.fourthline.cling.support.model.DIDLObject; //导入依赖的package包/类
/**
* Converts the content of a didlObject into a list of cling items.
*
* @param didlObject the content
* @return the list of cling items
*/
public List<Item> toItemList(DIDLObject didlObject) {
List<Item> items = new ArrayList<Item>();
if (didlObject instanceof Container) {
DIDLContent content = loadContainer((Container) didlObject);
if (content != null) {
items.addAll(content.getItems());
for (Container includedContainer : content.getContainers()) {
items.addAll(toItemList(includedContainer));
}
}
} else if (didlObject instanceof Item) {
items.add((Item) didlObject);
}
return items;
}
示例4: startItem
import org.fourthline.cling.support.model.DIDLObject; //导入依赖的package包/类
@Override
protected void startItem(PlayableItem playableItem, Object loadedItem) {
// Communicating with the activity is only possible after the activity
// is started
// if we send an broadcast event to early the activity won't be up
// because there is no known way to query the activity state
// we are sending the command delayed
DIDLObject.Property<URI> albumArtUriProperty = playableItem.getItem() == null ? null : playableItem.getItem().getFirstProperty(DIDLObject.Property.UPNP.ALBUM_ART_URI.class);
albumArtUri = (albumArtUriProperty == null) ? null : albumArtUriProperty.getValue();
commandExecutionTimer = new Timer();
commandExecutionTimer.schedule(new TimerTask() {
@Override
public void run() {
Intent intent = new Intent();
intent.setAction(BackgroundMusicBroadcastReceiver.ACTION_PLAY);
getContext().sendBroadcast(intent);
}
}, 600L);
}
示例5: onCreateContextMenu
import org.fourthline.cling.support.model.DIDLObject; //导入依赖的package包/类
/**
* Creates context menu for certain actions on a specific item.
*/
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
if (v instanceof ListView) {
ListView listView = (ListView) v;
Object item = listView.getAdapter().getItem(info.position);
if (item instanceof DIDLObject) {
selectedDIDLObject = (DIDLObject) item;
}
}
menu.setHeaderTitle(v.getContext().getString(
R.string.browse_context_title));
ArrayList<String> menuItems = new ArrayList<String>();
menuItems.add(v.getContext().getString(R.string.browse_context_play_all));
menuItems.add(v.getContext().getString(R.string.browse_context_play));
//menuItems.add(v.getContext().getString( R.string.browse_context_add_to_playplist));
menuItems.add(v.getContext()
.getString(R.string.browse_context_download));
for (int i = 0; i < menuItems.size(); i++) {
menu.add(Menu.NONE, i, i, menuItems.get(i));
}
}
示例6: createItem
import org.fourthline.cling.support.model.DIDLObject; //导入依赖的package包/类
private Item createItem(MediaFile song) throws Exception {
MediaFile parent = mediaFileService.getParentOf(song);
MusicTrack item = new MusicTrack();
item.setId(String.valueOf(song.getId()));
item.setParentID(String.valueOf(parent.getId()));
item.setTitle(song.getTitle());
item.setAlbum(song.getAlbumName());
if (song.getArtist() != null) {
item.setArtists(new PersonWithRole[]{new PersonWithRole(song.getArtist())});
}
Integer year = song.getYear();
if (year != null) {
item.setDate(year + "-01-01");
}
item.setOriginalTrackNumber(song.getTrackNumber());
if (song.getGenre() != null) {
item.setGenres(new String[]{song.getGenre()});
}
item.setResources(Arrays.asList(createResourceForSong(song)));
item.setDescription(song.getComment());
item.addProperty(new DIDLObject.Property.UPNP.ALBUM_ART_URI(getAlbumArtUrl(parent)));
return item;
}
示例7: generateContainer
import org.fourthline.cling.support.model.DIDLObject; //导入依赖的package包/类
/**
* 创建Container(容器)
*
* @param id
* container的id号
* @param title
* container的名称
* @param parentID
* container的父container的id号
* @param clazz
* upnp协议中有定义,请自行查看
* @param isLocal
* 是否在本地dms上创建
* @return 创建好的container
*/
public static Container generateContainer(String id, String title,
String parentID, String clazz, boolean isLocal) {
Container container = new Container();
container.setId(id);
container.setTitle(title);
container.setParentID(parentID);
container.setChildCount(0);
container.setRestricted(true);
container.setClazz(new DIDLObject.Class(clazz));
container.setSearchable(true);
container.setWriteStatus(WriteStatus.NOT_WRITABLE);
ContentTree.addRootContentNode();
ContentTree.getContentNode(parentID, isLocal).getContainer()
.addContainer(container);
ContentTree
.getContentNode(parentID, isLocal)
.getContainer()
.setChildCount(
ContentTree.getContentNode(parentID, isLocal)
.getContainer().getChildCount() + 1);
ContentTree.addContentNode(id, new ContentNode(id, container), isLocal);
return container;
}
示例8: generateRoot
import org.fourthline.cling.support.model.DIDLObject; //导入依赖的package包/类
protected void generateRoot(DIDLContent content, Document descriptor, boolean nestedItems) {
Element rootElement = descriptor.createElementNS(DIDLContent.NAMESPACE_URI, "DIDL-Lite");
descriptor.appendChild(rootElement);
// rootElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:didl", DIDLContent.NAMESPACE_URI);
rootElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:upnp", DIDLObject.Property.UPNP.NAMESPACE.URI);
rootElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:dc", DIDLObject.Property.DC.NAMESPACE.URI);
rootElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:sec", DIDLObject.Property.SEC.NAMESPACE.URI);
for (Container container : content.getContainers()) {
if (container == null) continue;
generateContainer(container, descriptor, rootElement, nestedItems);
}
for (Item item : content.getItems()) {
if (item == null) continue;
generateItem(item, descriptor, rootElement);
}
for (DescMeta descMeta : content.getDescMetadata()) {
if (descMeta == null) continue;
generateDescMetadata(descMeta, descriptor, rootElement);
}
}
示例9: endElement
import org.fourthline.cling.support.model.DIDLObject; //导入依赖的package包/类
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
super.endElement(uri, localName, qName);
if (DIDLObject.Property.UPNP.NAMESPACE.URI.equals(uri)) {
if ("searchClass".equals(localName)) {
getInstance().getSearchClasses().add(
new DIDLObject.Class(
getCharacters(),
getAttributes().getValue("name"),
"true".equals(getAttributes().getValue("includeDerived"))
)
);
} else if ("createClass".equals(localName)) {
getInstance().getCreateClasses().add(
new DIDLObject.Class(
getCharacters(),
getAttributes().getValue("name"),
"true".equals(getAttributes().getValue("includeDerived"))
)
);
}
}
}
示例10: getThumbUri
import org.fourthline.cling.support.model.DIDLObject; //导入依赖的package包/类
private String getThumbUri(ContentItem contentItem) {
String thumbUri = null;
int i = contentItem.getItem().getProperties().size();
for (int j = 0; j < i; j++) {
if (null != contentItem.getItem()
&& null != contentItem.getItem().getProperties()
&& null != contentItem.getItem().getProperties().get(j)
&& ((DIDLObject.Property) contentItem.getItem()
.getProperties().get(j)).getDescriptorName()
.equals("albumArtURI")) {
thumbUri = ((DIDLObject.Property) contentItem.getItem()
.getProperties().get(j)).getValue().toString();
break;
}
}
return thumbUri;
}
示例11: CustomContainer
import org.fourthline.cling.support.model.DIDLObject; //导入依赖的package包/类
public CustomContainer(String id, String parentID, String title, String creator, String baseURL)
{
this.setClazz(new DIDLObject.Class("object.container"));
if(parentID==null || parentID.compareTo(""+ContentDirectoryService.ROOT_ID)==0)
setId(id);
else if(id==null)
setId(parentID);
else
setId(parentID + ContentDirectoryService.SEPARATOR + id);
setParentID(parentID);
setTitle(title);
setCreator(creator);
setRestricted(true);
setSearchable(true);
setWriteStatus(WriteStatus.NOT_WRITABLE);
setChildCount(0);
this.baseURL = baseURL;
}
示例12: onItemClick
import org.fourthline.cling.support.model.DIDLObject; //导入依赖的package包/类
@Override
public void onItemClick(AdapterView<?> ada, View view, int position, long id) {
DIDLObject item = (DIDLObject) mBrowseItemAdapter.getItem(position);
if (item instanceof Container) {
String newObjectId = item.getId() == null ? "0"
: ((DIDLObject) mBrowseItemAdapter.getItem(position))
.getId();
Bundle args = new Bundle();
args.putString(DlnaDetailFragment.KEY_UDN, mUDN);
args.putString(DlnaDetailFragment.KEY_OBJECT_ID, newObjectId);
DlnaDetailFragment fragment = (DlnaDetailFragment) Fragment
.instantiate(getActivity(),
DlnaDetailFragment.class.getName(), args);
getFragmentManager()
.beginTransaction()
.replace(R.id.dlna_container, fragment,
DlnaDetailFragment.TAG).addToBackStack(null)
.commit();
} else {
performAction(item);
}
}
示例13: browseMeta
import org.fourthline.cling.support.model.DIDLObject; //导入依赖的package包/类
@Override
public DIDLObject browseMeta(YaaccContentDirectory contentDirectory,
String myId) {
MusicAlbum folder = new MusicAlbum(myId,
ContentDirectoryIDs.MUSIC_ARTISTS_FOLDER.getId(), getName(
contentDirectory, myId), "yaacc", getSize(
contentDirectory, myId));
return folder;
}
示例14: browseMeta
import org.fourthline.cling.support.model.DIDLObject; //导入依赖的package包/类
@Override
public DIDLObject browseMeta(YaaccContentDirectory contentDirectory, String myId) {
StorageFolder folder = new StorageFolder(ContentDirectoryIDs.MUSIC_ARTISTS_FOLDER.getId(), ContentDirectoryIDs.MUSIC_FOLDER.getId(), getContext().getString(R.string.artists), "yaacc", getSize(contentDirectory,myId),
907000L);
return folder;
}
示例15: browseMeta
import org.fourthline.cling.support.model.DIDLObject; //导入依赖的package包/类
@Override
public DIDLObject browseMeta(YaaccContentDirectory contentDirectory, String myId) {
StorageFolder folder = new StorageFolder(ContentDirectoryIDs.MUSIC_GENRES_FOLDER.getId(), ContentDirectoryIDs.MUSIC_FOLDER.getId(),getContext().getString(R.string.genres) , "yaacc", getSize(contentDirectory,myId),
907000L);
return folder;
}