java getitem方法_Java DIDLContent.getItems方法代码示例

import org.fourthline.cling.support.model.DIDLContent; //导入方法依赖的package包/类

/**

* Returns all player instances initialized with the given transport object

*

* @param transport the object which describes the content to be played

* @return the player

*/

public List initializePlayers(AvTransport transport) {

PlayableItem playableItem = new PlayableItem();

List items = new ArrayList();

if (transport == null) {

return PlayerFactory.createPlayer(this, transport.getSynchronizationInfo(), items);

}

Log.d(getClass().getName(), "TransportId: " + transport.getInstanceId());

PositionInfo positionInfo = transport.getPositionInfo();

Log.d(getClass().getName(), "positionInfo: " + positionInfo);

if (positionInfo == null) {

return PlayerFactory.createPlayer(this, transport.getSynchronizationInfo(), items);

}

DIDLContent metadata = null;

try {

if (positionInfo.getTrackMetaData() != null && positionInfo.getTrackMetaData().indexOf("NOT_IMPLEMENTED") == -1) {

metadata = new DIDLParser().parse(positionInfo.getTrackMetaData());

} else {

Log.d(getClass().getName(), "Warning unparsable TackMetaData: " + positionInfo.getTrackMetaData());

}

} catch (Exception e) {

Log.d(getClass().getName(), "Exception while parsing metadata: ", e);

}

String mimeType = "";

if (metadata != null) {

List metadataItems = metadata.getItems();

for (Item item : metadataItems) {

playableItem.setTitle(item.getTitle());

List metadataResources = item.getResources();

for (Res res : metadataResources) {

if (res.getProtocolInfo() != null) {

mimeType = res.getProtocolInfo().getContentFormatMimeType().toString();

break;

}

}

break;

}

} else {

playableItem.setTitle(positionInfo.getTrackURI().toString());

String fileExtension = MimeTypeMap.getFileExtensionFromUrl(positionInfo.getTrackURI());

mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtension);

Log.d(getClass().getName(), "fileextension from trackURI: " + fileExtension);

}

playableItem.setMimeType(mimeType);

playableItem.setUri(Uri.parse(positionInfo.getTrackURI()));

Log.d(getClass().getName(), "positionInfo.getTrackURI(): " + positionInfo.getTrackURI());

// FIXME Duration not supported in receiver yet

// playableItem.setDuration(duration)

items.add(playableItem);

Log.d(getClass().getName(), "TransportUri: " + positionInfo.getTrackURI());

Log.d(getClass().getName(), "Current duration: " + positionInfo.getTrackDuration());

Log.d(getClass().getName(), "TrackMetaData: " + positionInfo.getTrackMetaData());

Log.d(getClass().getName(), "MimeType: " + playableItem.getMimeType());

return PlayerFactory.createPlayer(this, transport.getSynchronizationInfo(), items);

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值