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


Java Res.setDuration方法代码示例

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


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

示例1: createResourceForSong

import org.fourthline.cling.support.model.Res; //导入方法依赖的package包/类
protected Res createResourceForSong(MediaFile song) {
    Player player = playerService.getGuestPlayer(null);

    UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(getBaseUrl() + "/ext/stream")
            .queryParam("id", song.getId())
            .queryParam("player", player.getId());

    if (song.isVideo()) {
        builder.queryParam("format", TranscodingService.FORMAT_RAW);
    }

    jwtSecurityService.addJWTToken(builder);

    String url = builder.toUriString();

    String suffix = song.isVideo() ? FilenameUtils.getExtension(song.getPath()) : transcodingService.getSuffix(player, song, null);
    String mimeTypeString = StringUtil.getMimeType(suffix);
    MimeType mimeType = mimeTypeString == null ? null : MimeType.valueOf(mimeTypeString);

    Res res = new Res(mimeType, null, url);
    res.setDuration(formatDuration(song.getDurationSeconds()));
    return res;
}
 
开发者ID:airsonic,项目名称:airsonic,代码行数:24,代码来源:CustomContentDirectory.java

示例2: browseItem

import org.fourthline.cling.support.model.Res; //导入方法依赖的package包/类
@Override
public List<Item> browseItem(YaaccContentDirectory contentDirectory, String myId) {
	List<Item> result = new ArrayList<Item>();
	String[] projection = { MediaStore.Video.Media._ID, MediaStore.Video.Media.DISPLAY_NAME, MediaStore.Video.Media.MIME_TYPE,
			MediaStore.Video.Media.SIZE, MediaStore.Video.Media.DURATION };
	String selection = "";
	String[] selectionArgs = null;
	Cursor mediaCursor = contentDirectory.getContext().getContentResolver().query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, projection, selection,
			selectionArgs, MediaStore.Video.Media.DISPLAY_NAME + " ASC");

	if (mediaCursor != null) {
		mediaCursor.moveToFirst();
		while (!mediaCursor.isAfterLast()) {
			String id = mediaCursor.getString(mediaCursor.getColumnIndex(MediaStore.Video.VideoColumns._ID));
			String name = mediaCursor.getString(mediaCursor.getColumnIndex(MediaStore.Video.VideoColumns.DISPLAY_NAME));
			String duration = mediaCursor.getString(mediaCursor.getColumnIndex(MediaStore.Video.VideoColumns.DURATION));
			duration = contentDirectory.formatDuration(duration);
			Long size = Long.valueOf(mediaCursor.getString(mediaCursor.getColumnIndex(MediaStore.Video.VideoColumns.SIZE)));
			Log.d(getClass().getName(), "Mimetype: " + mediaCursor.getString(mediaCursor.getColumnIndex(MediaStore.Video.VideoColumns.MIME_TYPE)));
			MimeType mimeType = MimeType.valueOf(mediaCursor.getString(mediaCursor.getColumnIndex(MediaStore.Video.VideoColumns.MIME_TYPE)));
			// file parameter only needed for media players which decide the
			// ability of playing a file by the file extension
               String uri = getUriString(contentDirectory, id, mimeType);
			Res resource = new Res(mimeType, size, uri);
			resource.setDuration(duration);
			result.add(new VideoItem(ContentDirectoryIDs.VIDEO_PREFIX.getId() +  id, ContentDirectoryIDs.VIDEOS_FOLDER.getId(), name, "", resource));
			Log.d(getClass().getName(), "VideoItem: " + id + " Name: " + name + " uri: " + uri);
			mediaCursor.moveToNext();
		}
		mediaCursor.close();
	} else {
		Log.d(getClass().getName(), "System media store is empty.");
	}
	return result;
	
}
 
开发者ID:theopenbit,项目名称:yaacc-code,代码行数:37,代码来源:VideosFolderBrowser.java

示例3: createResourceForSong

import org.fourthline.cling.support.model.Res; //导入方法依赖的package包/类
protected Res createResourceForSong(MediaFile song) {
    Player player = playerService.getGuestPlayer(null);
    String url = getBaseUrl() + "stream?id=" + song.getId() + "&player=" + player.getId();
    if (song.isVideo()) {
        url += "&format=" + TranscodingService.FORMAT_RAW;
    }

    String suffix = song.isVideo() ? FilenameUtils.getExtension(song.getPath()) : transcodingService.getSuffix(player, song, null);
    String mimeTypeString = StringUtil.getMimeType(suffix);
    MimeType mimeType = mimeTypeString == null ? null : MimeType.valueOf(mimeTypeString);

    Res res = new Res(mimeType, null, url);
    res.setDuration(formatDuration(song.getDurationSeconds()));
    return res;
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:16,代码来源:SubsonicContentDirectory.java

示例4: browseMeta

import org.fourthline.cling.support.model.Res; //导入方法依赖的package包/类
@Override
public DIDLObject browseMeta(YaaccContentDirectory contentDirectory,
                             String myId) {
    Item result = null;
    String[] projection = {MediaStore.Audio.Media._ID,
            MediaStore.Audio.Media.DISPLAY_NAME,
            MediaStore.Audio.Media.MIME_TYPE, MediaStore.Audio.Media.SIZE,
            MediaStore.Audio.Media.ALBUM, MediaStore.Audio.Media.ALBUM_ID,
            MediaStore.Audio.Media.TITLE, MediaStore.Audio.Media.ARTIST,
            MediaStore.Audio.Media.DURATION};
    String selection = MediaStore.Audio.Media._ID + "=?";
    String[] selectionArgs = new String[]{myId
            .substring(ContentDirectoryIDs.MUSIC_ALL_TITLES_ITEM_PREFIX
                    .getId().length())};
    Cursor mediaCursor = contentDirectory
            .getContext()
            .getContentResolver()
            .query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, projection,
                    selection, selectionArgs, null);

    if (mediaCursor != null) {
        mediaCursor.moveToFirst();
        String id = mediaCursor.getString(mediaCursor
                .getColumnIndex(MediaStore.Audio.Media._ID));
        String name = mediaCursor.getString(mediaCursor
                .getColumnIndex(MediaStore.Audio.Media.DISPLAY_NAME));
        Long size = Long.valueOf(mediaCursor.getString(mediaCursor
                .getColumnIndex(MediaStore.Audio.Media.SIZE)));

        String album = mediaCursor.getString(mediaCursor
                .getColumnIndex(MediaStore.Audio.Media.ALBUM));
        String albumId = mediaCursor.getString(mediaCursor
                .getColumnIndex(MediaStore.Audio.Media.ALBUM_ID));
        String title = mediaCursor.getString(mediaCursor
                .getColumnIndex(MediaStore.Audio.Media.TITLE));
        String artist = mediaCursor.getString(mediaCursor
                .getColumnIndex(MediaStore.Audio.Media.ARTIST));
        String duration = mediaCursor.getString(mediaCursor
                .getColumnIndex(MediaStore.Audio.Media.DURATION));
        duration = contentDirectory.formatDuration(duration);
        Log.d(getClass().getName(),
                "Mimetype: "
                        + mediaCursor.getString(mediaCursor
                        .getColumnIndex(MediaStore.Audio.Media.MIME_TYPE)));

        MimeType mimeType = MimeType.valueOf(mediaCursor
                .getString(mediaCursor
                        .getColumnIndex(MediaStore.Audio.Media.MIME_TYPE)));
        // file parameter only needed for media players which decide
        // the
        // ability of playing a file by the file extension

        String uri = getUriString(contentDirectory, id, mimeType);
        URI albumArtUri = URI.create("http://"
                + contentDirectory.getIpAddress() + ":"
                + YaaccUpnpServerService.PORT + "/?album=" + albumId);
        Res resource = new Res(mimeType, size, uri);
        resource.setDuration(duration);
        MusicTrack musicTrack = new MusicTrack(
                ContentDirectoryIDs.MUSIC_ALL_TITLES_ITEM_PREFIX.getId()
                        + id,
                ContentDirectoryIDs.MUSIC_ALL_TITLES_FOLDER.getId(), title
                + "-(" + name + ")", "", album, artist, resource);
        musicTrack
                .replaceFirstProperty(new UPNP.ALBUM_ART_URI(albumArtUri));
        result = musicTrack;
        Log.d(getClass().getName(), "MusicTrack: " + id + " Name: " + name
                + " uri: " + uri);

        mediaCursor.close();
    } else {
        Log.d(getClass().getName(), "Item " + myId + "  not found.");
    }

    return result;
}
 
开发者ID:theopenbit,项目名称:yaacc-code,代码行数:77,代码来源:MusicAllTitleItemBrowser.java

示例5: browseMeta

import org.fourthline.cling.support.model.Res; //导入方法依赖的package包/类
@Override
public DIDLObject browseMeta(YaaccContentDirectory contentDirectory,
		String myId) {
	Item result = null;
	String[] projection = { MediaStore.Audio.Media._ID,
			MediaStore.Audio.Media.DISPLAY_NAME,
			MediaStore.Audio.Media.MIME_TYPE, MediaStore.Audio.Media.SIZE,
			MediaStore.Audio.Media.ALBUM, MediaStore.Audio.Media.ALBUM_ID,
			MediaStore.Audio.Media.ARTIST_ID, MediaStore.Audio.Media.TITLE,
			MediaStore.Audio.Media.ARTIST, MediaStore.Audio.Media.DURATION };
	String selection = MediaStore.Audio.Media._ID + "=?";
	String[] selectionArgs = new String[] { myId
			.substring(ContentDirectoryIDs.MUSIC_ARTIST_ITEM_PREFIX.getId()
					.length()) };
	Cursor mediaCursor = contentDirectory
			.getContext()
			.getContentResolver()
			.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, projection,
					selection, selectionArgs, null);

	if (mediaCursor != null) {
		mediaCursor.moveToFirst();
		String id = mediaCursor.getString(mediaCursor
				.getColumnIndex(MediaStore.Audio.Media._ID));
		String name = mediaCursor.getString(mediaCursor
				.getColumnIndex(MediaStore.Audio.Media.DISPLAY_NAME));
		Long size = Long.valueOf(mediaCursor.getString(mediaCursor
				.getColumnIndex(MediaStore.Audio.Media.SIZE)));

		String album = mediaCursor.getString(mediaCursor
				.getColumnIndex(MediaStore.Audio.Media.ALBUM));
		String albumId = mediaCursor.getString(mediaCursor
				.getColumnIndex(MediaStore.Audio.Media.ALBUM));
		String artistId = mediaCursor.getString(mediaCursor
				.getColumnIndex(MediaStore.Audio.Media.ARTIST_ID));
		String title = mediaCursor.getString(mediaCursor
				.getColumnIndex(MediaStore.Audio.Media.TITLE));
		String artist = mediaCursor.getString(mediaCursor
				.getColumnIndex(MediaStore.Audio.Media.ARTIST));
		String duration = mediaCursor.getString(mediaCursor
				.getColumnIndex(MediaStore.Audio.Media.DURATION));
		duration = contentDirectory.formatDuration(duration);
		Log.d(getClass().getName(),
				"Mimetype: "
						+ mediaCursor.getString(mediaCursor
								.getColumnIndex(MediaStore.Audio.Media.MIME_TYPE)));

		MimeType mimeType = MimeType.valueOf(mediaCursor
				.getString(mediaCursor
						.getColumnIndex(MediaStore.Audio.Media.MIME_TYPE)));
		// file parameter only needed for media players which decide
		// the
		// ability of playing a file by the file extension

           String uri = getUriString(contentDirectory, id, mimeType);
		URI albumArtUri = URI.create("http://"
				+ contentDirectory.getIpAddress() + ":"
				+ YaaccUpnpServerService.PORT + "/?album=" + albumId);
		Res resource = new Res(mimeType, size, uri);
		resource.setDuration(duration);
		MusicTrack musicTrack = new MusicTrack(
				ContentDirectoryIDs.MUSIC_ARTIST_ITEM_PREFIX.getId() + id,
				ContentDirectoryIDs.MUSIC_ARTIST_PREFIX.getId() + artistId,
				title + "-(" + name + ")", "", album, artist, resource);
		musicTrack
				.replaceFirstProperty(new UPNP.ALBUM_ART_URI(albumArtUri));
		result = musicTrack;
		Log.d(getClass().getName(), "MusicTrack: " + id + " Name: " + name
				+ " uri: " + uri);

		mediaCursor.close();
	} else {
		Log.d(getClass().getName(), "Item " + myId + "  not found.");
	}

	return result;
}
 
开发者ID:theopenbit,项目名称:yaacc-code,代码行数:78,代码来源:MusicArtistItemBrowser.java

示例6: browseMeta

import org.fourthline.cling.support.model.Res; //导入方法依赖的package包/类
@Override
public DIDLObject browseMeta(YaaccContentDirectory contentDirectory,
                             String myId) {
    Item result = null;
    String[] projection = {MediaStore.Audio.Media._ID,
            MediaStore.Audio.Media.DISPLAY_NAME,
            MediaStore.Audio.Media.MIME_TYPE, MediaStore.Audio.Media.SIZE,
            MediaStore.Audio.Media.ALBUM, MediaStore.Audio.Media.ALBUM_ID,
            MediaStore.Audio.Media.TITLE, MediaStore.Audio.Media.ARTIST,
            MediaStore.Audio.Media.DURATION};
    String selection = MediaStore.Audio.Media._ID + "=?";
    String[] selectionArgs = new String[]{myId
            .substring(ContentDirectoryIDs.MUSIC_ALBUM_ITEM_PREFIX.getId()
                    .length())};
    Cursor mediaCursor = contentDirectory
            .getContext()
            .getContentResolver()
            .query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, projection,
                    selection, selectionArgs, MediaStore.Audio.Media.DISPLAY_NAME + " ASC");

    if (mediaCursor != null) {
        mediaCursor.moveToFirst();
        String id = mediaCursor.getString(mediaCursor
                .getColumnIndex(MediaStore.Audio.Media._ID));
        String name = mediaCursor.getString(mediaCursor
                .getColumnIndex(MediaStore.Audio.Media.DISPLAY_NAME));
        Long size = Long.valueOf(mediaCursor.getString(mediaCursor
                .getColumnIndex(MediaStore.Audio.Media.SIZE)));

        String album = mediaCursor.getString(mediaCursor
                .getColumnIndex(MediaStore.Audio.Media.ALBUM));
        String albumId = mediaCursor.getString(mediaCursor
                .getColumnIndex(MediaStore.Audio.Media.ALBUM_ID));
        String title = mediaCursor.getString(mediaCursor
                .getColumnIndex(MediaStore.Audio.Media.TITLE));
        String artist = mediaCursor.getString(mediaCursor
                .getColumnIndex(MediaStore.Audio.Media.ARTIST));
        String duration = mediaCursor.getString(mediaCursor
                .getColumnIndex(MediaStore.Audio.Media.DURATION));
        duration = contentDirectory.formatDuration(duration);
        Log.d(getClass().getName(),
                "Mimetype: "
                        + mediaCursor.getString(mediaCursor
                        .getColumnIndex(MediaStore.Audio.Media.MIME_TYPE)));

        MimeType mimeType = MimeType.valueOf(mediaCursor
                .getString(mediaCursor
                        .getColumnIndex(MediaStore.Audio.Media.MIME_TYPE)));
        // file parameter only needed for media players which decide
        // the
        // ability of playing a file by the file extension

        String uri = getUriString(contentDirectory, id, mimeType);
        URI albumArtUri = URI.create("http://"
                + contentDirectory.getIpAddress() + ":"
                + YaaccUpnpServerService.PORT + "/?album=" + albumId);
        Res resource = new Res(mimeType, size, uri);
        resource.setDuration(duration);
        MusicTrack musicTrack = new MusicTrack(
                ContentDirectoryIDs.MUSIC_ALBUM_ITEM_PREFIX.getId() + id,
                ContentDirectoryIDs.MUSIC_ALBUM_PREFIX.getId() + albumId,
                title + "-(" + name + ")", "", album, artist, resource);
        musicTrack
                .replaceFirstProperty(new UPNP.ALBUM_ART_URI(albumArtUri));
        result = musicTrack;
        Log.d(getClass().getName(), "MusicTrack: " + id + " Name: " + name
                + " uri: " + uri);

        mediaCursor.close();
    } else {
        Log.d(getClass().getName(), "Item " + myId + "  not found.");
    }

    return result;
}
 
开发者ID:theopenbit,项目名称:yaacc-code,代码行数:76,代码来源:MusicAlbumItemBrowser.java

示例7: addVideoContent

import org.fourthline.cling.support.model.Res; //导入方法依赖的package包/类
/**
     * 添加视频
     */
    private void addVideoContent(Context context, ContentNode rootNode) {

        Container videoContainer = new Container();
        videoContainer.setClazz(new DIDLObject.Class("object.container"));
        videoContainer.setId(ContentTree.VIDEO_ID);
        videoContainer.setParentID(ContentTree.ROOT_ID);
        videoContainer.setTitle("Videos");
        videoContainer.setRestricted(true);
        videoContainer.setWriteStatus(WriteStatus.NOT_WRITABLE);
        videoContainer.setChildCount(0);

        rootNode.getContainer().addContainer(videoContainer);
        rootNode.getContainer().setChildCount(
                rootNode.getContainer().getChildCount() + 1);
        ContentTree.addNode(ContentTree.VIDEO_ID, new ContentNode(
                ContentTree.VIDEO_ID, videoContainer));

        Cursor cursor = context.getContentResolver()
                .query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
                        null, null, null, null);
        if (cursor == null) {
            return;
        }
        while (cursor.moveToNext()) {
            String id = ContentTree.VIDEO_PREFIX
                    + cursor.getInt(cursor.getColumnIndex(MediaStore.Video.Media._ID));
            String title = cursor.getString(cursor
                    .getColumnIndexOrThrow(MediaStore.Video.Media.TITLE));
            String creator = cursor.getString(cursor
                    .getColumnIndexOrThrow(MediaStore.Video.Media.ARTIST));
            String filePath = cursor.getString(cursor
                    .getColumnIndexOrThrow(MediaStore.Video.Media.DATA));
            String mimeType = cursor.getString(cursor
                    .getColumnIndexOrThrow(MediaStore.Video.Media.MIME_TYPE));
            long size = cursor.getLong(cursor
                    .getColumnIndexOrThrow(MediaStore.Video.Media.SIZE));
            long duration = cursor.getLong(cursor
                    .getColumnIndexOrThrow(MediaStore.Video.Media.DURATION));
            String resolution = cursor.getString(cursor
                    .getColumnIndexOrThrow(MediaStore.Video.Media.RESOLUTION));
            Res res = new Res(new MimeType(mimeType.substring(0, mimeType.indexOf('/')),
                    mimeType.substring(mimeType.indexOf('/') + 1)), size,
                    "http://" + address + "/" + id);
            res.setDuration(duration / (1000 * 60 * 60) + ":"
                    + (duration % (1000 * 60 * 60)) / (1000 * 60) + ":"
                    + (duration % (1000 * 60)) / 1000);
            res.setResolution(resolution);

            VideoItem videoItem = new VideoItem(id, ContentTree.VIDEO_ID, title, creator, res);
            videoContainer.addItem(videoItem);
            videoContainer.setChildCount(videoContainer.getChildCount() + 1);
            ContentTree.addNode(id, new ContentNode(id, videoItem, filePath));

//            Log.d(TAG, "added video item " + title + "from " + filePath);
        }

        cursor.close();
    }
 
开发者ID:hezhubo,项目名称:HPlayer,代码行数:62,代码来源:GenerateContentTask.java

示例8: addAudioContent

import org.fourthline.cling.support.model.Res; //导入方法依赖的package包/类
/**
     * 添加音频
     */
    private void addAudioContent(Context context, ContentNode rootNode) {

        Container audioContainer = new Container(ContentTree.AUDIO_ID,
                ContentTree.ROOT_ID, "Audios", "HPlayer MediaServer",
                new DIDLObject.Class("object.container"), 0);
        audioContainer.setRestricted(true);
        audioContainer.setWriteStatus(WriteStatus.NOT_WRITABLE);

        rootNode.getContainer().addContainer(audioContainer);
        rootNode.getContainer().setChildCount(
                rootNode.getContainer().getChildCount() + 1);
        ContentTree.addNode(ContentTree.AUDIO_ID, new ContentNode(
                ContentTree.AUDIO_ID, audioContainer));

        Cursor cursor = context.getContentResolver()
                .query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
                        null, null, null, null);
        if (cursor == null) {
            return;
        }

        while (cursor.moveToNext()) {
            String id = ContentTree.AUDIO_PREFIX
                    + cursor.getInt(cursor.getColumnIndex(MediaStore.Audio.Media._ID));
            String title = cursor.getString(cursor
                    .getColumnIndexOrThrow(MediaStore.Audio.Media.TITLE));
            String creator = cursor.getString(cursor
                    .getColumnIndexOrThrow(MediaStore.Audio.Media.ARTIST));
            String filePath = cursor.getString(cursor
                    .getColumnIndexOrThrow(MediaStore.Audio.Media.DATA));
            String mimeType = cursor.getString(cursor
                    .getColumnIndexOrThrow(MediaStore.Audio.Media.MIME_TYPE));
            long size = cursor.getLong(cursor
                    .getColumnIndexOrThrow(MediaStore.Audio.Media.SIZE));
            long duration = cursor.getLong(cursor
                    .getColumnIndexOrThrow(MediaStore.Audio.Media.DURATION));
            String album = cursor.getString(cursor
                    .getColumnIndexOrThrow(MediaStore.Audio.Media.ALBUM));
            Res res = new Res(new MimeType(mimeType.substring(0, mimeType.indexOf('/')),
                    mimeType.substring(mimeType.indexOf('/') + 1)), size,
                    "http://" + address + "/" + id);
            res.setDuration(duration / (1000 * 60 * 60) + ":"
                    + (duration % (1000 * 60 * 60)) / (1000 * 60) + ":"
                    + (duration % (1000 * 60)) / 1000);

            // Music Track must have `artist' with role field, or
            // DIDLParser().generate(didl) will throw nullpointException
            MusicTrack musicTrack = new MusicTrack(id,
                    ContentTree.AUDIO_ID, title, creator, album,
                    new PersonWithRole(creator, "Performer"), res);
            audioContainer.addItem(musicTrack);
            audioContainer.setChildCount(audioContainer.getChildCount() + 1);
            ContentTree.addNode(id, new ContentNode(id, musicTrack, filePath));

//            Log.d(TAG, "added audio item " + title + "from " + filePath);
        }

        cursor.close();
    }
 
开发者ID:hezhubo,项目名称:HPlayer,代码行数:63,代码来源:GenerateContentTask.java

示例9: createResource

import org.fourthline.cling.support.model.Res; //导入方法依赖的package包/类
protected Res createResource(Attributes attributes) {
    Res res = new Res();

    if (attributes.getValue("importUri") != null)
        res.setImportUri(URI.create(attributes.getValue("importUri")));

    try {
        res.setProtocolInfo(
                new ProtocolInfo(attributes.getValue("protocolInfo"))
        );
    } catch (InvalidValueException ex) {
        log.warning("In DIDL content, invalid resource protocol info: " + Exceptions.unwrap(ex));
        return null;
    }

    if (attributes.getValue("size") != null)
        res.setSize(Long.valueOf(attributes.getValue("size")));

    if (attributes.getValue("duration") != null)
        res.setDuration(attributes.getValue("duration"));

    if (attributes.getValue("bitrate") != null)
        res.setBitrate(Long.valueOf(attributes.getValue("bitrate")));

    if (attributes.getValue("sampleFrequency") != null)
        res.setSampleFrequency(Long.valueOf(attributes.getValue("sampleFrequency")));

    if (attributes.getValue("bitsPerSample") != null)
        res.setBitsPerSample(Long.valueOf(attributes.getValue("bitsPerSample")));

    if (attributes.getValue("nrAudioChannels") != null)
        res.setNrAudioChannels(Long.valueOf(attributes.getValue("nrAudioChannels")));

    if (attributes.getValue("colorDepth") != null)
        res.setColorDepth(Long.valueOf(attributes.getValue("colorDepth")));

    if (attributes.getValue("protection") != null)
        res.setProtection(attributes.getValue("protection"));

    if (attributes.getValue("resolution") != null)
        res.setResolution(attributes.getValue("resolution"));

    return res;
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:45,代码来源:DIDLParser.java

示例10: getContainers

import org.fourthline.cling.support.model.Res; //导入方法依赖的package包/类
@Override
public List<Container> getContainers()
{
	String[] columns = {
		MediaStore.Audio.Media._ID,
		MediaStore.Audio.Media.TITLE,
		MediaStore.Audio.Media.DATA,
		MediaStore.Audio.Media.ARTIST,
		MediaStore.Audio.Media.MIME_TYPE,
		MediaStore.Audio.Media.SIZE,
		MediaStore.Audio.Media.DURATION,
		MediaStore.Audio.Media.ALBUM
	};

	Cursor cursor = ctx.getContentResolver().query(uri, columns, where, whereVal, orderBy);
	if(cursor!=null)
	{
		if (cursor.moveToFirst())
		{
			do
			{
				String id = ContentDirectoryService.AUDIO_PREFIX + cursor.getInt(cursor.getColumnIndex(MediaStore.Audio.Media._ID));
				String title = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.TITLE));
				String creator = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ARTIST));
				String filePath = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA));
				String mimeType = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.MIME_TYPE));
				long size = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.SIZE));
				long duration = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DURATION));
				String album = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ALBUM));

				String extension = "";
				int dot = filePath.lastIndexOf('.');
				if (dot >= 0)
					extension = filePath.substring(dot).toLowerCase();

				Res res = new Res(new MimeType(mimeType.substring(0, mimeType.indexOf('/')),
					mimeType.substring(mimeType.indexOf('/') + 1)), size, "http://" + baseURL + "/" + id + extension);

				res.setDuration(duration / (1000 * 60 * 60) + ":"
					+ (duration % (1000 * 60 * 60)) / (1000 * 60) + ":"
					+ (duration % (1000 * 60)) / 1000);

				addItem(new MusicTrack(id, parentID, title, creator, album, new PersonWithRole(creator, "Performer"), res));

				Log.v(TAG, "Added audio item " + title + " from " + filePath);

			} while (cursor.moveToNext());
		}
		cursor.close();
	}

	return containers;
}
 
开发者ID:trishika,项目名称:DroidUPnP,代码行数:54,代码来源:AudioContainer.java

示例11: getContainers

import org.fourthline.cling.support.model.Res; //导入方法依赖的package包/类
@Override
public List<Container> getContainers()
{
	String[] columns = {
		MediaStore.Video.Media._ID,
		MediaStore.Video.Media.TITLE,
		MediaStore.Video.Media.DATA,
		MediaStore.Video.Media.ARTIST,
		MediaStore.Video.Media.MIME_TYPE,
		MediaStore.Video.Media.SIZE,
		MediaStore.Video.Media.DURATION,
		MediaStore.Images.Media.HEIGHT,
		MediaStore.Images.Media.WIDTH,
	};

	Cursor cursor = ctx.getContentResolver().query(uri, columns, where, whereVal, orderBy);
	if(cursor!=null)
	{
		if (cursor.moveToFirst())
		{
			do
			{
				String id = ContentDirectoryService.VIDEO_PREFIX + cursor.getInt(cursor.getColumnIndex(MediaStore.Video.Media._ID));
				String title = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.TITLE));
				String creator = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.ARTIST));
				String filePath = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA));
				String mimeType = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.MIME_TYPE));
				long size = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.SIZE));
				long duration = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DURATION));
				long height = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.HEIGHT));
				long width = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.WIDTH));

				String extension = "";
				int dot = filePath.lastIndexOf('.');
				if (dot >= 0)
					extension = filePath.substring(dot).toLowerCase();

				Res res = new Res(new MimeType(mimeType.substring(0, mimeType.indexOf('/')),
					mimeType.substring(mimeType.indexOf('/') + 1)), size, "http://" + baseURL + "/" + id + extension);
				res.setDuration(duration / (1000 * 60 * 60) + ":"
					+ (duration % (1000 * 60 * 60)) / (1000 * 60) + ":"
					+ (duration % (1000 * 60)) / 1000);
				res.setResolution((int) width, (int) height);

				addItem(new VideoItem(id, parentID, title, creator, res));

				Log.v(TAG, "Added video item " + title + " from " + filePath);

			} while (cursor.moveToNext());
		}
		cursor.close();
	}

	return containers;
}
 
开发者ID:trishika,项目名称:DroidUPnP,代码行数:56,代码来源:VideoContainer.java


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