Search in sources :

Example 1 with Container

use of org.fourthline.cling.support.model.container.Container in project BeyondUPnP by kevinshine.

the class ContentContainerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.listview);
    mObjectId = getIntent().getStringExtra(OBJECT_ID_TAG);
    mIdentifierString = getIntent().getStringExtra(IDENTIFIER_STRING_TAG);
    String title = getIntent().getStringExtra(CONTENT_CONTAINER_TITLE);
    //Display container title.
    if (title != null) {
        setTitle(title);
    } else {
        setTitle("");
    }
    mDidlObjectAdapter = new DIDLObjectAdapter(ContentContainerActivity.this);
    ListView listView = (ListView) findViewById(android.R.id.list);
    listView.setAdapter(mDidlObjectAdapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            DIDLObject didlObject = mDidlObjectAdapter.getItem(position);
            if (didlObject instanceof Container) {
                Intent intent = new Intent(ContentContainerActivity.this, ContentContainerActivity.class);
                intent.putExtra(ContentContainerActivity.OBJECT_ID_TAG, didlObject.getId());
                intent.putExtra(ContentContainerActivity.IDENTIFIER_STRING_TAG, mIdentifierString);
                intent.putExtra(ContentContainerActivity.CONTENT_CONTAINER_TITLE, didlObject.getTitle());
                startActivity(intent);
            } else if (didlObject instanceof Item) {
                Item item = (Item) didlObject;
                playItem(item);
            }
        }
    });
    loadContent();
}
Also used : Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) MenuItem(android.view.MenuItem) PlaylistItem(com.kevinshen.beyondupnp.database.BeyondUpnpContract.PlaylistItem) Item(org.fourthline.cling.support.model.item.Item) Container(org.fourthline.cling.support.model.container.Container) ListView(android.widget.ListView) DIDLObject(org.fourthline.cling.support.model.DIDLObject) AdapterView(android.widget.AdapterView)

Example 2 with Container

use of org.fourthline.cling.support.model.container.Container in project libresonic by Libresonic.

the class FolderBasedContentDirectory method createContainer.

private Container createContainer(MediaFile mediaFile) throws Exception {
    Container container = mediaFile.isAlbum() ? createAlbumContainer(mediaFile) : new MusicAlbum();
    container.setId(CONTAINER_ID_FOLDER_PREFIX + mediaFile.getId());
    container.setTitle(mediaFile.getName());
    List<MediaFile> children = mediaFileService.getChildrenOf(mediaFile, true, true, false);
    container.setChildCount(children.size());
    container.setParentID(CONTAINER_ID_ROOT);
    if (!mediaFileService.isRoot(mediaFile)) {
        MediaFile parent = mediaFileService.getParentOf(mediaFile);
        if (parent != null) {
            container.setParentID(String.valueOf(parent.getId()));
        }
    }
    return container;
}
Also used : Container(org.fourthline.cling.support.model.container.Container) PlaylistContainer(org.fourthline.cling.support.model.container.PlaylistContainer) MusicAlbum(org.fourthline.cling.support.model.container.MusicAlbum)

Example 3 with Container

use of org.fourthline.cling.support.model.container.Container in project BeyondUPnP by kevinshine.

the class BeyondContentDirectoryService method browse.

@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);
}
Also used : Item(org.fourthline.cling.support.model.item.Item) Container(org.fourthline.cling.support.model.container.Container) DIDLParser(org.fourthline.cling.support.contentdirectory.DIDLParser) ContentDirectoryException(org.fourthline.cling.support.contentdirectory.ContentDirectoryException) DIDLContent(org.fourthline.cling.support.model.DIDLContent) BrowseResult(org.fourthline.cling.support.model.BrowseResult) ContentDirectoryException(org.fourthline.cling.support.contentdirectory.ContentDirectoryException)

Example 4 with Container

use of org.fourthline.cling.support.model.container.Container in project libresonic by Libresonic.

the class FolderBasedContentDirectory method createPlaylistRootContainer.

private Container createPlaylistRootContainer() {
    Container container = new StorageFolder();
    container.setId(CONTAINER_ID_PLAYLIST_ROOT);
    container.setTitle("Playlists");
    List<Playlist> playlists = playlistService.getAllPlaylists();
    container.setChildCount(playlists.size());
    container.setParentID(CONTAINER_ID_ROOT);
    return container;
}
Also used : Container(org.fourthline.cling.support.model.container.Container) PlaylistContainer(org.fourthline.cling.support.model.container.PlaylistContainer) StorageFolder(org.fourthline.cling.support.model.container.StorageFolder)

Aggregations

Container (org.fourthline.cling.support.model.container.Container)4 PlaylistContainer (org.fourthline.cling.support.model.container.PlaylistContainer)2 Item (org.fourthline.cling.support.model.item.Item)2 Intent (android.content.Intent)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 PlaylistItem (com.kevinshen.beyondupnp.database.BeyondUpnpContract.PlaylistItem)1 ContentDirectoryException (org.fourthline.cling.support.contentdirectory.ContentDirectoryException)1 DIDLParser (org.fourthline.cling.support.contentdirectory.DIDLParser)1 BrowseResult (org.fourthline.cling.support.model.BrowseResult)1 DIDLContent (org.fourthline.cling.support.model.DIDLContent)1 DIDLObject (org.fourthline.cling.support.model.DIDLObject)1 MusicAlbum (org.fourthline.cling.support.model.container.MusicAlbum)1 StorageFolder (org.fourthline.cling.support.model.container.StorageFolder)1