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


Java Res类代码示例

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


Res类属于org.fourthline.cling.support.model包,在下文中一共展示了Res类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: playItems

import org.fourthline.cling.support.model.Res; //导入依赖的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

示例3: startPhotoShow

import org.fourthline.cling.support.model.Res; //导入依赖的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

示例4: playItem

import org.fourthline.cling.support.model.Res; //导入依赖的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

示例5: startElement

import org.fourthline.cling.support.model.Res; //导入依赖的package包/类
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
    super.startElement(uri, localName, qName, attributes);

    if (!DIDLContent.NAMESPACE_URI.equals(uri)) return;

    if (localName.equals("res")) {

        Res res = createResource(attributes);
        if (res != null) {
            getInstance().addResource(res);
            createResHandler(res, this);
        }

    } else if (localName.equals("desc")) {

        DescMeta desc = createDescMeta(attributes);
        getInstance().addDescMetadata(desc);
        createDescMetaHandler(desc, this);

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

示例6: getRealImagePath

import org.fourthline.cling.support.model.Res; //导入依赖的package包/类
public static String getRealImagePath(ContentItem paramContentItem) {
	int[] arrayOfInt = new int[paramContentItem.getItem().getResources()
			.size()];
	String str1 = "";
	int i = 0;
	// i = paramContentItem.getItem().getResources().size();
	// if (str1.equals(""))
	// return str1;
	if (((Res) paramContentItem.getItem().getResources().get(i)).getValue() != null) {
		String str2 = ((Res) paramContentItem.getItem().getResources()
				.get(i)).getResolution();
		if (str2 != null) {
			str1 = ((Res) paramContentItem.getItem().getResources().get(i))
					.getValue();
			String[] arrayOfString = str2.split("x");
			arrayOfInt[i] = (Integer.parseInt(arrayOfString[0]) * Integer
					.parseInt(arrayOfString[1]));
		}
	}
	// ++i;
	// str1 = ((Res) paramContentItem.getItem().getResources()
	// .get(getMaxID(arrayOfInt))).getValue();

	return str1;
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:26,代码来源:Utils.java

示例7: createPhotos

import org.fourthline.cling.support.model.Res; //导入依赖的package包/类
private List<Photo> createPhotos(String parentId) {


		String album = ("kde-look.org");
		String creator = "http://kde-look.org/CONTENT/content-files/156304-DSC_0089-2-1600.jpg"; 				
		MimeType mimeType = new MimeType("image", "jpeg");
		List<Photo> result = new ArrayList<Photo>();
		
		String url = "http://kde-look.org/CONTENT/content-files/156304-DSC_0089-2-1600.jpg";
		creator = url;
		Photo photo = new Photo("201",parentId,url,creator,album,new Res(mimeType,123456l,url));
		content.put(photo.getId(), photo);
		result.add(photo); 
		url = "http://kde-look.org/CONTENT/content-files/156246-DSC_0021-1600.jpg";
		creator = url;
		photo=new Photo("202",parentId,url,creator,album,new Res(mimeType,123456l,url));
		content.put(photo.getId(), photo);		
		result.add(photo);		
		url = "http://kde-look.org/CONTENT/content-files/156225-raining-bolt-1920x1200.JPG";
		creator = url;
		content.put(photo.getId(), photo);
		photo=new Photo("203",parentId,url,creator,album,new Res(mimeType,123456l,url));
		result.add(photo);
		url = "http://kde-look.org/CONTENT/content-files/156223-kungsleden1900x1200.JPG";
		creator = url;
		photo=new Photo("204",parentId,url,creator,album,new Res(mimeType,123456l,url));
		content.put(photo.getId(), photo);
		result.add(photo);
		url = "http://kde-look.org/CONTENT/content-files/156218-DSC_0012-1600.jpg";
		creator = url;
		photo= new Photo("204",parentId,url,creator,album,new Res(mimeType,123456l,url));
		content.put(photo.getId(), photo);
		result.add(photo);		
		return result;
	}
 
开发者ID:theopenbit,项目名称:yaacc-code,代码行数:36,代码来源:ContentDirectory.java

示例8: streamMp3

import org.fourthline.cling.support.model.Res; //导入依赖的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

示例9: testInfoInstance

import org.fourthline.cling.support.model.Res; //导入依赖的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

示例10: 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

示例11: PlayableItem

import org.fourthline.cling.support.model.Res; //导入依赖的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

示例12: setAVTransportURI

import org.fourthline.cling.support.model.Res; //导入依赖的package包/类
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);
}
 
开发者ID:hezhubo,项目名称:HPlayer,代码行数:37,代码来源:UpnpControlSet.java

示例13: 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

示例14: getAudioList

import org.fourthline.cling.support.model.Res; //导入依赖的package包/类
public static List<Item> getAudioList(String serverUrl, String parentId) {
    List<Item> items = new ArrayList<>();

    //Query all track,add to items
    Cursor c = BeyondApplication.getApplication().getContentResolver()
            .query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, null, null, null, MediaStore.Audio.Media.TITLE);
    c.moveToFirst();
    while (!c.isAfterLast()) {
        long id = c.getLong(c.getColumnIndex(MediaStore.Audio.Media._ID));
        String title = c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Media.TITLE));
        String creator = c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Media.ARTIST));
        String album = c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Media.ALBUM));

        String data = c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA));
        //Remove SDCard path
        data = data.replaceFirst(storageDir, "");
        //Replace file name by "id.ext"
        String fileName = data.substring(data.lastIndexOf(File.separator));
        String ext = fileName.substring(fileName.lastIndexOf("."));
        data = data.replace(fileName, File.separator + id + ext);

        String mimeType = c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Media.MIME_TYPE));
        long size = c.getLong(c.getColumnIndexOrThrow(MediaStore.Audio.Media.SIZE));
        long duration = c.getLong(c.getColumnIndexOrThrow(MediaStore.Audio.Media.DURATION));
        //Get duration string
        String durationStr = ModelUtil.toTimeString(duration);

        //Compose audio url
        String url = serverUrl + File.separator + "audio" + File.separator + data;
        Res res = new Res(mimeType, size, durationStr, null, url);

        items.add(new MusicTrack(String.valueOf(id), parentId, title, creator, album, new PersonWithRole(creator), res));

        c.moveToNext();
    }

    return items;
}
 
开发者ID:kevinshine,项目名称:BeyondUPnP,代码行数:39,代码来源:MediaResourceDao.java

示例15: getVideoList

import org.fourthline.cling.support.model.Res; //导入依赖的package包/类
public static List<Item> getVideoList(String serverUrl, String parentId) {
    List<Item> items = new ArrayList<>();

    Cursor c = BeyondApplication.getApplication().getContentResolver()
            .query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, null, null, null, MediaStore.Video.Media.TITLE);
    c.moveToFirst();
    while (!c.isAfterLast()) {
        long id = c.getLong(c.getColumnIndex(MediaStore.Audio.Media._ID));
        String title = c.getString(c.getColumnIndexOrThrow(MediaStore.Video.Media.TITLE));
        String creator = c.getString(c.getColumnIndexOrThrow(MediaStore.Video.Media.ARTIST));

        String data = c.getString(c.getColumnIndexOrThrow(MediaStore.Video.Media.DATA));
        //Remove SDCard path
        data = data.replaceFirst(storageDir, "");
        //Replace file name by "id.ext"
        String fileName = data.substring(data.lastIndexOf(File.separator));
        String ext = fileName.substring(fileName.lastIndexOf("."));
        data = data.replace(fileName, File.separator + id + ext);

        String mimeType = c.getString(c.getColumnIndexOrThrow(MediaStore.Video.Media.MIME_TYPE));
        long size = c.getLong(c.getColumnIndexOrThrow(MediaStore.Video.Media.SIZE));
        long duration = c.getLong(c.getColumnIndexOrThrow(MediaStore.Video.Media.DURATION));
        //Get duration string
        String durationStr = ModelUtil.toTimeString(duration);

        //Compose audio url
        String url = serverUrl + File.separator + "video" + File.separator + data;
        Res res = new Res(mimeType, size, durationStr, null, url);

        items.add(new Movie(String.valueOf(id), parentId, title, creator, res));

        c.moveToNext();
    }

    return items;
}
 
开发者ID:kevinshine,项目名称:BeyondUPnP,代码行数:37,代码来源:MediaResourceDao.java


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