当前位置: 首页>>代码示例>>Java>>正文


Java Item.getFirstResource方法代码示例

本文整理汇总了Java中org.fourthline.cling.support.model.item.Item.getFirstResource方法的典型用法代码示例。如果您正苦于以下问题:Java Item.getFirstResource方法的具体用法?Java Item.getFirstResource怎么用?Java Item.getFirstResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.fourthline.cling.support.model.item.Item的用法示例。


在下文中一共展示了Item.getFirstResource方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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);
}
 
开发者ID:stephenmcgruer,项目名称:simple-upnp,代码行数:24,代码来源:FileBrowserFragment.java

示例2: 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
	}
}
 
开发者ID:theopenbit,项目名称:yaacc-code,代码行数:25,代码来源:UpnpClientTest.java

示例3: 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);
}
 
开发者ID:kevinshine,项目名称:BeyondUPnP,代码行数:20,代码来源:ContentContainerActivity.java

示例4: streamMp3

import org.fourthline.cling.support.model.item.Item; //导入方法依赖的package包/类
protected void streamMp3(String instanceId, String upnpServerid) {
	UpnpClient upnpClient = new UpnpClient();
	Device<?, ?, ?> device = lookupDevice(upnpClient, upnpServerid);
	ContentDirectoryBrowseResult browseResult = null;
	if (device != null) {
		Log.d(getClass().getName(), "#####Device: " + device);
		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(),
					"Duration: " + resource.getDuration());
			Log.d(getClass().getName(),
					"ProtocolInfo: " + resource.getProtocolInfo());
			Log.d(getClass().getName(), "ContentFormat: "
					+ resource.getProtocolInfo().getContentFormat());
			Log.d(getClass().getName(), "Value: " + resource.getValue());
			intentView(resource.getProtocolInfo().getContentFormat(),
					Uri.parse(resource.getValue()));
		}

	}
}
 
开发者ID:theopenbit,项目名称:yaacc-code,代码行数:30,代码来源:UpnpClientTest.java

示例5: testInfoInstance

import org.fourthline.cling.support.model.item.Item; //导入方法依赖的package包/类
public void testInfoInstance() throws Exception {
	UpnpClient upnpClient = new UpnpClient();
	final List<Device<?, ?, ?>> devices = searchDevices(upnpClient);
	ContentDirectoryBrowseResult browseResult = null;
	for (Device<?, ?, ?> device : devices) {
		Log.d(getClass().getName(),
				"#####Device: " + device.getDisplayString());
		browseResult = upnpClient.browseSync(device, "202");
		List<Item> items = new ArrayList<Item>();
		if(	browseResult.getResult() != null) {
				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(),
					"Duration: " + resource.getDuration());
			Log.d(getClass().getName(),
					"ProtocolInfo: " + resource.getProtocolInfo());
			Log.d(getClass().getName(), "ContentFormat: "
					+ resource.getProtocolInfo().getContentFormat());
			Log.d(getClass().getName(), "Value: " + resource.getValue());

		}

	}

}
 
开发者ID:theopenbit,项目名称:yaacc-code,代码行数:35,代码来源:UpnpClientTest.java

示例6: PlayableItem

import org.fourthline.cling.support.model.item.Item; //导入方法依赖的package包/类
@SuppressLint("SimpleDateFormat")
public PlayableItem(Item item, int defaultDuration){
	this.item =item;
	setTitle(item.getTitle());		
	Res resource = item.getFirstResource();
	if (resource != null) {
		setUri(Uri.parse(resource.getValue()));
           String mimeType =resource.getProtocolInfo().getContentFormat();
           if(mimeType == null || mimeType.equals("")){
               String fileExtension = MimeTypeMap.getFileExtensionFromUrl(getUri().toString());
               mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtension);
           }
		setMimeType(mimeType);

		// calculate duration

		long millis = defaultDuration;
		if (resource.getDuration() != null) {
		    try{
                   String[] tokens = resource.getDuration().split(":");
				millis = (Long.valueOf(tokens[0]) * 3600 + Long.valueOf(tokens[1]) * 60 + Long.valueOf(tokens[2])) * 1000;

                   Log.d(getClass().getName(), "resource.getDuration(): " + resource.getDuration() +" millis: " + millis);

			} catch (Exception e) {
				Log.d(getClass().getName(), "bad duration format", e);
			}
		}
		setDuration(millis);			
	}
}
 
开发者ID:theopenbit,项目名称:yaacc-code,代码行数:32,代码来源:PlayableItem.java

示例7: startMusicPlay

import org.fourthline.cling.support.model.item.Item; //导入方法依赖的package包/类
protected void startMusicPlay(UpnpClient upnpClient,
		Device<?, ?, ?> device, boolean background, 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(), "Duration: " + resource.getDuration());
		Log.d(getClass().getName(),
				"ProtocolInfo: " + resource.getProtocolInfo());
		Log.d(getClass().getName(), "ContentFormat: "
				+ resource.getProtocolInfo().getContentFormat());
		Log.d(getClass().getName(), "Value: " + resource.getValue());
		SimpleDateFormat dateFormat = new SimpleDateFormat("hh:mm:ss");

		// just for a test
		int millis = 0;
		try {
			Date date = dateFormat.parse(resource.getDuration());
			millis = date.getHours() * 60 * 60 * 1000;
			millis += date.getMinutes() * 60 * 1000;
			millis += date.getSeconds() * 1000;
			assertEquals(date.getTime(), millis);
			Log.d(getClass().getName(),
					"HappyHappy Joy Joy Duration in Millis=" + millis);
			Log.d(getClass().getName(), "Playing: " + item.getTitle());
			if (background) {
				Log.d(getClass().getName(),
						"Starting Background service... ");
				Intent svc = new Intent(getContext(),
						BackgroundMusicService.class);
				svc.setData(Uri.parse(resource.getValue()));
				getContext().startService(svc);
			} else {
				intentView(resource.getProtocolInfo().getContentFormat(),
						Uri.parse(resource.getValue()));
			}
		} catch (ParseException e) {
			Log.d(getClass().getName(), "bad duration format");
			;
		}
		myWait(millis);

	}
}
 
开发者ID:theopenbit,项目名称:yaacc-code,代码行数:52,代码来源:UpnpClientTest.java


注:本文中的org.fourthline.cling.support.model.item.Item.getFirstResource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。