本文整理汇总了Java中org.fourthline.cling.support.model.item.Item类的典型用法代码示例。如果您正苦于以下问题:Java Item类的具体用法?Java Item怎么用?Java Item使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Item类属于org.fourthline.cling.support.model.item包,在下文中一共展示了Item类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createItem
import org.fourthline.cling.support.model.item.Item; //导入依赖的package包/类
public 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.getId())));
return item;
}
示例2: createItem
import org.fourthline.cling.support.model.item.Item; //导入依赖的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;
}
示例3: createItem
import org.fourthline.cling.support.model.item.Item; //导入依赖的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;
}
示例4: playItems
import org.fourthline.cling.support.model.item.Item; //导入依赖的package包/类
@Override
public void playItems(List<Item> itemsToPlay) {
if (mListener == null)
return;
// Convert to MediaQueueItem for Cast.
List<MediaQueueItem> mediaItems = new ArrayList<>();
for (Item item : itemsToPlay) {
// Assumption: first non-null resource is the URL. No idea if correct.
Res urlResource = item.getFirstResource();
if (urlResource != null) {
MediaMetadata metadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MUSIC_TRACK);
metadata.putString(MediaMetadata.KEY_TITLE, item.getTitle());
MediaInfo mediaInfo = new MediaInfo.Builder(urlResource.getValue())
.setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
.setContentType("audio/mp3")
.setMetadata(metadata)
.build();
mediaItems.add(new MediaQueueItem.Builder(mediaInfo).build());
}
}
mListener.playFiles(mediaItems);
}
示例5: startPhotoShow
import org.fourthline.cling.support.model.item.Item; //导入依赖的package包/类
protected void startPhotoShow(UpnpClient upnpClient,
Device<?, ?, ?> device, long durationInMillis, String instanceId) {
ContentDirectoryBrowseResult browseResult;
browseResult = upnpClient.browseSync(device, instanceId);
List<Item> items = browseResult.getResult().getItems();
for (Item item : items) {
Log.d(getClass().getName(), "ParentId: " + item.getParentID());
Log.d(getClass().getName(), "ItemId: " + item.getId());
Res resource = item.getFirstResource();
if (resource == null)
break;
Log.d(getClass().getName(), "ImportUri: " + resource.getImportUri());
Log.d(getClass().getName(),
"ProtocolInfo: " + resource.getProtocolInfo());
Log.d(getClass().getName(), "ContentFormat: "
+ resource.getProtocolInfo().getContentFormat());
Log.d(getClass().getName(), "Value: " + resource.getValue());
Log.d(getClass().getName(), "Picture: " + item.getTitle());
intentView(resource.getProtocolInfo().getContentFormat(),
Uri.parse(resource.getValue()), ImageViewerActivity.class);
myWait(durationInMillis); // Wait a bit between photo switch
}
}
示例6: testUseCaseBrowse
import org.fourthline.cling.support.model.item.Item; //导入依赖的package包/类
public void testUseCaseBrowse() {
UpnpClient upnpClient = getInitializedUpnpClientWithLocalServer();
Device<?, ?, ?> device = upnpClient.getDevice(LocalUpnpServer.UDN_ID);
ContentDirectoryBrowseResult result = upnpClient.browseSync(device,
"1", BrowseFlag.DIRECT_CHILDREN, "", 0, 999l, null);
if (result != null && result.getResult() != null) {
for (Container container : result.getResult().getContainers()) {
Log.d(getClass().getName(),
"Container: " + container.getTitle() + " ("
+ container.getChildCount() + ")");
}
for (Item item : result.getResult().getItems()) {
Log.d(getClass().getName(), "Item: "
+ item.getTitle()
+ " ("
+ item.getFirstResource().getProtocolInfo()
.getContentFormat() + ")");
}
assertEquals(3, result.getResult().getItems().size());
}
}
示例7: initializePlayers
import org.fourthline.cling.support.model.item.Item; //导入依赖的package包/类
/**
* Returns all player instances initialized with the given didl object
*
* @param items the items to be played
* @return the player
*/
public List<Player> initializePlayers(List<Item> items) {
LinkedList<PlayableItem> playableItems = new LinkedList<PlayableItem>();
for (Item currentItem : items) {
PlayableItem playableItem = new PlayableItem(currentItem, getDefaultDuration());
playableItems.add(playableItem);
}
SynchronizationInfo synchronizationInfo = new SynchronizationInfo();
synchronizationInfo.setOffset(getDeviceSyncOffset()); //device specific offset
Calendar now = Calendar.getInstance(Locale.getDefault());
now.add(Calendar.MILLISECOND, Integer.valueOf(preferences.getString(context.getString(R.string.settings_default_playback_delay_key), "0")));
String referencedPresentationTime = new SyncOffset(true, now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.MINUTE), now.get(Calendar.SECOND), now.get(Calendar.MILLISECOND), 0, 0).toString();
Log.d(getClass().getName(), "CurrentTime: " + new Date().toString() + " representationTime: " + referencedPresentationTime);
synchronizationInfo.setReferencedPresentationTime(referencedPresentationTime);
return PlayerFactory.createPlayer(this, synchronizationInfo, playableItems);
}
示例8: toItemList
import org.fourthline.cling.support.model.item.Item; //导入依赖的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;
}
示例9: playAll
import org.fourthline.cling.support.model.item.Item; //导入依赖的package包/类
private void playAll() {
if(currentObject == null){
return;
}
ContentDirectoryBrowseResult result = upnpClient.browseSync(new Position(currentObject.getParentID(), upnpClient.getProviderDevice().getIdentity().getUdn().getIdentifierString()));
if (result == null || (result.getResult() != null && result.getResult().getItems().size() == 0)) {
Log.d(getClass().getName(), "Browse result of parent no direct items found...");
if(result.getResult() != null && result.getResult().getContainers().size() > 0){
play(upnpClient.initializePlayers(upnpClient.toItemList(result.getResult())));
}else {
play(upnpClient.initializePlayers(currentObject));
}
} else {
List<Item> items = result.getResult() == null ? new ArrayList<Item>(): result.getResult().getItems();
Log.d(getClass().getName(), "Browse result items: " + items.size());
int index = items.indexOf(currentObject);
if(index > 0){
//sort selected item to the beginning
List<Item> tempItems = new ArrayList<Item>(items.subList(index,items.size()-1));
tempItems.addAll(items.subList(0,index-1));
items = tempItems;
}
play(upnpClient.initializePlayers(items));
}
}
示例10: playItem
import org.fourthline.cling.support.model.item.Item; //导入依赖的package包/类
private void playItem(Item item){
if (item == null) return;
Res res = item.getFirstResource();
String uri = res.getValue();
DIDLContent content = new DIDLContent();
content.addItem(item);
DIDLParser didlParser = new DIDLParser();
String metadata = null;
try {
metadata = didlParser.generate(content);
} catch (Exception e) {
//ignore
}
//Log.d(TAG,"Item metadata:" + metadata);
//Play on the selected device.
PlaybackCommand.playNewItem(uri,metadata);
}
示例11: browse
import org.fourthline.cling.support.model.item.Item; //导入依赖的package包/类
@Override
public BrowseResult browse(String objectID, BrowseFlag browseFlag, String filter, long firstResult, long maxResults, SortCriterion[] orderby) throws ContentDirectoryException {
String address = Utils.getIPAddress(true);
String serverUrl = "http://" + address + ":" + JettyResourceServer.JETTY_SERVER_PORT;
//Create container by id
Container resultBean = ContainerFactory.createContainer(objectID, serverUrl);
DIDLContent content = new DIDLContent();
for (Container c : resultBean.getContainers())
content.addContainer(c);
for (Item item : resultBean.getItems())
content.addItem(item);
int count = resultBean.getChildCount();
String contentModel = "";
try {
contentModel = new DIDLParser().generate(content);
} catch (Exception e) {
throw new ContentDirectoryException(
ContentDirectoryErrorCode.CANNOT_PROCESS, e.toString());
}
return new BrowseResult(contentModel, count, count);
}
示例12: createItem
import org.fourthline.cling.support.model.item.Item; //导入依赖的package包/类
protected Item createItem(Attributes attributes) {
Item item = new Item();
item.setId(attributes.getValue("id"));
item.setParentID(attributes.getValue("parentID"));
try {
Boolean value = (Boolean)Datatype.Builtin.BOOLEAN.getDatatype().valueOf(
attributes.getValue("restricted")
);
if (value != null)
item.setRestricted(value);
} catch (Exception ex) {
// Ignore
}
if ((attributes.getValue("refID") != null))
item.setRefID(attributes.getValue("refID"));
return item;
}
示例13: generateRoot
import org.fourthline.cling.support.model.item.Item; //导入依赖的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);
}
}
示例14: startElement
import org.fourthline.cling.support.model.item.Item; //导入依赖的package包/类
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
super.startElement(uri, localName, qName, attributes);
if (!DIDLContent.NAMESPACE_URI.equals(uri)) return;
if (localName.equals("container")) {
Container container = createContainer(attributes);
getInstance().addContainer(container);
createContainerHandler(container, this);
} else if (localName.equals("item")) {
Item item = createItem(attributes);
getInstance().addItem(item);
createItemHandler(item, this);
} else if (localName.equals("desc")) {
DescMeta desc = createDescMeta(attributes);
getInstance().addDescMetadata(desc);
createDescMetaHandler(desc, this);
}
}
示例15: onItemClick
import org.fourthline.cling.support.model.item.Item; //导入依赖的package包/类
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
FileBrowserAdapter.ListItem listItem = (FileBrowserAdapter.ListItem) adapterView.getItemAtPosition(position);
if (listItem.isPreviousContainerListItem()) {
onBackPressed();
} else if (listItem.holdsContainer()) {
selectContainer(listItem.getContainer());
} else {
List<Item> items = new ArrayList<>();
items.add(listItem.getItem());
playItems(items);
}
}