org.fourthline.cling.support.avtransport.callback.SetAVTransportURI Java Examples

The following examples show how to use org.fourthline.cling.support.avtransport.callback.SetAVTransportURI. 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: UpnpControlSet.java    From HPlayer with Apache License 2.0 5 votes vote down vote up
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 #2
Source File: DLNAController.java    From Popeens-DSub with GNU General Public License v3.0 4 votes vote down vote up
private void startSongRemote(final DownloadFile currentPlaying, final boolean autoStart, final int position) {
	if(currentPlaying == null) {
		downloadService.setPlayerState(PlayerState.IDLE);
		return;
	}
	error = false;

	downloadService.setPlayerState(PlayerState.PREPARING);

	try {
		Pair<String, String> songInfo = getSongInfo(currentPlaying);

		currentPlayingURI = songInfo.getFirst();
		controlPoint.execute(new SetAVTransportURI(getTransportService(), songInfo.getFirst(), songInfo.getSecond()) {
			@Override
			public void success(ActionInvocation invocation) {
				if(position != 0) {
					changePosition(position);
				}

				if (autoStart) {
					start();
				} else {
					downloadService.setPlayerState(PlayerState.PAUSED);
				}

				currentPosition = position;
				lastUpdate.set(System.currentTimeMillis());
				getUpdatedStatus();
			}

			@Override
			public void failure(ActionInvocation actionInvocation, UpnpResponse upnpResponse, String msg) {
				Log.w(TAG, "Set URI failed: " + msg);
				failedLoad();
			}
		});
	} catch (Exception e) {
		Log.w(TAG, "Failed startSong", e);
		failedLoad();
	}
}