org.fourthline.cling.support.contentdirectory.DIDLParser Java Examples
The following examples show how to use
org.fourthline.cling.support.contentdirectory.DIDLParser.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ContentContainerActivity.java From BeyondUPnP with Apache License 2.0 | 6 votes |
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); }
Example #2
Source File: BeyondContentDirectoryService.java From BeyondUPnP with Apache License 2.0 | 6 votes |
@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); }
Example #3
Source File: Browse.java From TVRemoteIME with GNU General Public License v2.0 | 5 votes |
public void success(ActionInvocation invocation) { log.fine("Successful browse action, reading output argument values"); BrowseResult result = new BrowseResult( invocation.getOutput("Result").getValue().toString(), (UnsignedIntegerFourBytes) invocation.getOutput("NumberReturned").getValue(), (UnsignedIntegerFourBytes) invocation.getOutput("TotalMatches").getValue(), (UnsignedIntegerFourBytes) invocation.getOutput("UpdateID").getValue() ); boolean proceed = receivedRaw(invocation, result); if (proceed && result.getCountLong() > 0 && result.getResult().length() > 0) { try { DIDLParser didlParser = new DIDLParser(); DIDLContent didl = didlParser.parse(result.getResult()); received(invocation, didl); updateStatus(Status.OK); } catch (Exception ex) { invocation.setFailure( new ActionException(ErrorCode.ACTION_FAILED, "Can't parse DIDL XML response: " + ex, ex) ); failure(invocation, null); } } else { received(invocation, new DIDLContent()); updateStatus(Status.NO_CONTENT); } }
Example #4
Source File: Search.java From TVRemoteIME with GNU General Public License v2.0 | 5 votes |
@Override public void success(ActionInvocation actionInvocation) { log.fine("Successful search action, reading output argument values"); SearchResult result = new SearchResult( actionInvocation.getOutput("Result").getValue().toString(), (UnsignedIntegerFourBytes) actionInvocation.getOutput("NumberReturned").getValue(), (UnsignedIntegerFourBytes) actionInvocation.getOutput("TotalMatches").getValue(), (UnsignedIntegerFourBytes) actionInvocation.getOutput("UpdateID").getValue()); boolean proceed = receivedRaw(actionInvocation, result); if (proceed && result.getCountLong() > 0 && result.getResult().length() > 0) { try { DIDLParser didlParser = new DIDLParser(); DIDLContent didl = didlParser.parse(result.getResult()); received(actionInvocation, didl); updateStatus(Status.OK); } catch (Exception ex) { actionInvocation.setFailure( new ActionException(ErrorCode.ACTION_FAILED, "Can't parse DIDL XML response: " + ex, ex) ); failure(actionInvocation, null); } } else { received(actionInvocation, new DIDLContent()); updateStatus(Status.NO_CONTENT); } }
Example #5
Source File: UpnpControlSet.java From HPlayer with Apache License 2.0 | 5 votes |
public void setAVTransportURI(String url, int schedule, String title, String id, String creator, String parentID) { alreadyPlay = false; currentPosition = schedule; //TODO 此处有问题 究竟如何才是正确的DLNA推屏数据? DIDLParser didlParser = new DIDLParser(); DIDLContent content = new DIDLContent(); Res res = new Res(); Movie movie = new Movie(id, parentID, title, creator, res); content.addItem(movie); String didlString = ""; try { didlString = didlParser.generate(content); } catch (Exception e) { e.printStackTrace(); } ActionCallback setAVTransport = new SetAVTransportURI( avTransportService, url, didlString) { @Override public void failure(ActionInvocation arg0, UpnpResponse arg1, String arg2) { onFailureCallBack(SET_AVTRANSPORT, arg2); } @Override public void success(ActionInvocation invocation) { onVideoPlay(); // TODO 究竟如何将当前进度一起推送过去,让播放器播放时自动跳转? // TODO DLNA 是否支持这个尚不清楚 getDMRTransportInfo();// 远程渲染器播放准备完成不会主动告诉终端,需获取状态来做进度推送 onSuccessCallBack(SET_AVTRANSPORT); } }; mUpnpService.getControlPoint().execute(setAVTransport); }
Example #6
Source File: Browse.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
public void success(ActionInvocation invocation) { log.fine("Successful browse action, reading output argument values"); BrowseResult result = new BrowseResult( invocation.getOutput("Result").getValue().toString(), (UnsignedIntegerFourBytes) invocation.getOutput("NumberReturned").getValue(), (UnsignedIntegerFourBytes) invocation.getOutput("TotalMatches").getValue(), (UnsignedIntegerFourBytes) invocation.getOutput("UpdateID").getValue() ); boolean proceed = receivedRaw(invocation, result); if (proceed && result.getCountLong() > 0 && result.getResult().length() > 0) { try { DIDLParser didlParser = new DIDLParser(); DIDLContent didl = didlParser.parse(result.getResult()); received(invocation, didl); updateStatus(Status.OK); } catch (Exception ex) { invocation.setFailure( new ActionException(ErrorCode.ACTION_FAILED, "Can't parse DIDL XML response: " + ex, ex) ); failure(invocation, null); } } else { received(invocation, new DIDLContent()); updateStatus(Status.NO_CONTENT); } }
Example #7
Source File: Search.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
@Override public void success(ActionInvocation actionInvocation) { log.fine("Successful search action, reading output argument values"); SearchResult result = new SearchResult( actionInvocation.getOutput("Result").getValue().toString(), (UnsignedIntegerFourBytes) actionInvocation.getOutput("NumberReturned").getValue(), (UnsignedIntegerFourBytes) actionInvocation.getOutput("TotalMatches").getValue(), (UnsignedIntegerFourBytes) actionInvocation.getOutput("UpdateID").getValue()); boolean proceed = receivedRaw(actionInvocation, result); if (proceed && result.getCountLong() > 0 && result.getResult().length() > 0) { try { DIDLParser didlParser = new DIDLParser(); DIDLContent didl = didlParser.parse(result.getResult()); received(actionInvocation, didl); updateStatus(Status.OK); } catch (Exception ex) { actionInvocation.setFailure( new ActionException(ErrorCode.ACTION_FAILED, "Can't parse DIDL XML response: " + ex, ex) ); failure(actionInvocation, null); } } else { received(actionInvocation, new DIDLContent()); updateStatus(Status.NO_CONTENT); } }
Example #8
Source File: CustomContentDirectory.java From airsonic-advanced with GNU General Public License v3.0 | 4 votes |
protected BrowseResult createBrowseResult(DIDLContent didl, int count, int totalMatches) throws Exception { return new BrowseResult(new DIDLParser().generate(didl), count, totalMatches); }
Example #9
Source File: UpnpContentProcessor.java From airsonic-advanced with GNU General Public License v3.0 | 4 votes |
protected BrowseResult createBrowseResult(DIDLContent didl, int count, int totalMatches) throws Exception { return new BrowseResult(new DIDLParser().generate(didl), count, totalMatches); }
Example #10
Source File: CustomContentDirectory.java From airsonic with GNU General Public License v3.0 | 4 votes |
protected BrowseResult createBrowseResult(DIDLContent didl, int count, int totalMatches) throws Exception { return new BrowseResult(new DIDLParser().generate(didl), count, totalMatches); }
Example #11
Source File: UpnpContentProcessor.java From airsonic with GNU General Public License v3.0 | 4 votes |
protected BrowseResult createBrowseResult(DIDLContent didl, int count, int totalMatches) throws Exception { return new BrowseResult(new DIDLParser().generate(didl), count, totalMatches); }
Example #12
Source File: ContentDirectoryService.java From HPlayer with Apache License 2.0 | 4 votes |
@Override public BrowseResult browse(String objectID, BrowseFlag browseFlag, String s1, long l, long l1, SortCriterion[] sortCriterions) throws ContentDirectoryException { try { DIDLContent didl = new DIDLContent(); ContentNode contentNode = ContentTree.getNode(objectID); Log.d(TAG, "someone's browsing id: " + objectID); if (contentNode == null) { // 没有共享资源 return new BrowseResult("", 0, 0); } if (contentNode.isItem()) { // 是文件 didl.addItem(contentNode.getItem()); Log.v(TAG, "returing item: " + contentNode.getItem().getTitle()); return new BrowseResult(new DIDLParser().generate(didl), 1, 1); } else { // 是文件夹 if (browseFlag == BrowseFlag.METADATA) { didl.addContainer(contentNode.getContainer()); Log.v(TAG, "returning metadata of container: " + contentNode.getContainer().getTitle()); return new BrowseResult(new DIDLParser().generate(didl), 1, 1); } else { for (Container container : contentNode.getContainer().getContainers()) { didl.addContainer(container); Log.v(TAG, "getting child container: " + container.getTitle()); } for (Item item : contentNode.getContainer().getItems()) { didl.addItem(item); Log.v(TAG, "getting child item: " + item.getTitle()); } return new BrowseResult(new DIDLParser().generate(didl), contentNode.getContainer().getChildCount(), contentNode.getContainer().getChildCount()); } } } catch (Exception e) { throw new ContentDirectoryException( ContentDirectoryErrorCode.CANNOT_PROCESS, e.toString()); } }
Example #13
Source File: SubsonicContentDirectory.java From subsonic with GNU General Public License v3.0 | 4 votes |
protected BrowseResult createBrowseResult(DIDLContent didl, int count, int totalMatches) throws Exception { return new BrowseResult(new DIDLParser().generate(didl), count, totalMatches); }
Example #14
Source File: ContentDirectoryService.java From DroidDLNA with GNU General Public License v3.0 | 4 votes |
@Override public BrowseResult browse(String objectID, BrowseFlag browseFlag, String filter, long firstResult, long maxResults, SortCriterion[] orderby) throws ContentDirectoryException { // TODO Auto-generated method stub try { DIDLContent didl = new DIDLContent(); ContentNode contentNode = ContentTree.getNode(objectID); Log.v(LOGTAG, "someone's browsing id: " + objectID); if (contentNode == null) return new BrowseResult("", 0, 0); if (contentNode.isItem()) { didl.addItem(contentNode.getItem()); Log.v(LOGTAG, "returing item: " + contentNode.getItem().getTitle()); return new BrowseResult(new DIDLParser().generate(didl), 1, 1); } else { if (browseFlag == BrowseFlag.METADATA) { didl.addContainer(contentNode.getContainer()); Log.v(LOGTAG, "returning metadata of container: " + contentNode.getContainer().getTitle()); return new BrowseResult(new DIDLParser().generate(didl), 1, 1); } else { for (Container container : contentNode.getContainer() .getContainers()) { didl.addContainer(container); Log.v(LOGTAG, "getting child container: " + container.getTitle()); } for (Item item : contentNode.getContainer().getItems()) { didl.addItem(item); Log.v(LOGTAG, "getting child item: " + item.getTitle()); } return new BrowseResult(new DIDLParser().generate(didl), contentNode.getContainer().getChildCount(), contentNode.getContainer().getChildCount()); } } } catch (Exception ex) { throw new ContentDirectoryException( ContentDirectoryErrorCode.CANNOT_PROCESS, ex.toString()); } }