org.fourthline.cling.support.avtransport.lastchange.AVTransportVariable Java Examples

The following examples show how to use org.fourthline.cling.support.avtransport.lastchange.AVTransportVariable. 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: ZxtMediaPlayer.java    From TVRemoteIME with GNU General Public License v2.0 6 votes vote down vote up
synchronized public void setURI(URI uri, String type, String name, String currentURIMetaData) {
    Log.i(TAG, "setURI " + uri);

    currentMediaInfo = new MediaInfo(uri.toString(),currentURIMetaData);
    currentPositionInfo = new PositionInfo(1, "", uri.toString());

    getAvTransportLastChange().setEventedValue(getInstanceId(),
            new AVTransportVariable.AVTransportURI(uri),
            new AVTransportVariable.CurrentTrackURI(uri));

    transportStateChanged(TransportState.STOPPED);
    
    IJKPlayer.setMediaListener(new GstMediaListener());
    
    Intent intent = new Intent();
    intent.setClass(mContext, RenderPlayerService.class);
    intent.putExtra("type", type);
    intent.putExtra("name", name);
    intent.putExtra("playURI", uri.toString());
    mContext.startService(intent);
}
 
Example #2
Source File: ZxtMediaPlayer.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
synchronized public void setURI(URI uri, String type, String name, String currentURIMetaData) {
    Log.i(TAG, "setURI " + uri);

    currentMediaInfo = new MediaInfo(uri.toString(),currentURIMetaData);
    currentPositionInfo = new PositionInfo(1, "", uri.toString());

    getAvTransportLastChange().setEventedValue(getInstanceId(),
            new AVTransportVariable.AVTransportURI(uri),
            new AVTransportVariable.CurrentTrackURI(uri));

    transportStateChanged(TransportState.STOPPED);
    
    GPlayer.setMediaListener(new GstMediaListener());
    
    Intent intent = new Intent();
    intent.setClass(mContext, RenderPlayerService.class);
    intent.putExtra("type", type);
    intent.putExtra("name", name);
    intent.putExtra("playURI", uri.toString());
    mContext.startService(intent);
}
 
Example #3
Source File: AbstractAVTransportService.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void appendCurrentState(LastChange lc, UnsignedIntegerFourBytes instanceId) throws Exception {

    MediaInfo mediaInfo = getMediaInfo(instanceId);
    TransportInfo transportInfo = getTransportInfo(instanceId);
    TransportSettings transportSettings = getTransportSettings(instanceId);
    PositionInfo positionInfo = getPositionInfo(instanceId);
    DeviceCapabilities deviceCaps = getDeviceCapabilities(instanceId);

    lc.setEventedValue(
            instanceId,
            new AVTransportVariable.AVTransportURI(URI.create(mediaInfo.getCurrentURI())),
            new AVTransportVariable.AVTransportURIMetaData(mediaInfo.getCurrentURIMetaData()),
            new AVTransportVariable.CurrentMediaDuration(mediaInfo.getMediaDuration()),
            new AVTransportVariable.CurrentPlayMode(transportSettings.getPlayMode()),
            new AVTransportVariable.CurrentRecordQualityMode(transportSettings.getRecQualityMode()),
            new AVTransportVariable.CurrentTrack(positionInfo.getTrack()),
            new AVTransportVariable.CurrentTrackDuration(positionInfo.getTrackDuration()),
            new AVTransportVariable.CurrentTrackMetaData(positionInfo.getTrackMetaData()),
            new AVTransportVariable.CurrentTrackURI(URI.create(positionInfo.getTrackURI())),
            new AVTransportVariable.CurrentTransportActions(getCurrentTransportActions(instanceId)),
            new AVTransportVariable.NextAVTransportURI(URI.create(mediaInfo.getNextURI())),
            new AVTransportVariable.NextAVTransportURIMetaData(mediaInfo.getNextURIMetaData()),
            new AVTransportVariable.NumberOfTracks(mediaInfo.getNumberOfTracks()),
            new AVTransportVariable.PossiblePlaybackStorageMedia(deviceCaps.getPlayMedia()),
            new AVTransportVariable.PossibleRecordQualityModes(deviceCaps.getRecQualityModes()),
            new AVTransportVariable.PossibleRecordStorageMedia(deviceCaps.getRecMedia()),
            new AVTransportVariable.RecordMediumWriteStatus(mediaInfo.getWriteStatus()),
            new AVTransportVariable.RecordStorageMedium(mediaInfo.getRecordMedium()),
            new AVTransportVariable.TransportPlaySpeed(transportInfo.getCurrentSpeed()),
            new AVTransportVariable.TransportState(transportInfo.getCurrentTransportState()),
            new AVTransportVariable.TransportStatus(transportInfo.getCurrentTransportStatus())
    );
}
 
Example #4
Source File: NoMediaPresent.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public void onEntry() {
    log.fine("Setting transport state to NO_MEDIA_PRESENT");
    getTransport().setTransportInfo(
            new TransportInfo(
                    TransportState.NO_MEDIA_PRESENT,
                    getTransport().getTransportInfo().getCurrentTransportStatus(),
                    getTransport().getTransportInfo().getCurrentSpeed()
            )
    );
    getTransport().getLastChange().setEventedValue(
            getTransport().getInstanceId(),
            new AVTransportVariable.TransportState(TransportState.NO_MEDIA_PRESENT),
            new AVTransportVariable.CurrentTransportActions(getCurrentTransportActions())
    );
}
 
Example #5
Source File: Stopped.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public void onEntry() {
    log.fine("Setting transport state to STOPPED");
    getTransport().setTransportInfo(
            new TransportInfo(
                    TransportState.STOPPED,
                    getTransport().getTransportInfo().getCurrentTransportStatus(),
                    getTransport().getTransportInfo().getCurrentSpeed()
            )
    );
    getTransport().getLastChange().setEventedValue(
            getTransport().getInstanceId(),
            new AVTransportVariable.TransportState(TransportState.STOPPED),
            new AVTransportVariable.CurrentTransportActions(getCurrentTransportActions())
    );
}
 
Example #6
Source File: PausedPlay.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public void onEntry() {
    log.fine("Setting transport state to PAUSED_PLAYBACK");
    getTransport().setTransportInfo(
            new TransportInfo(
                    TransportState.PAUSED_PLAYBACK,
                    getTransport().getTransportInfo().getCurrentTransportStatus(),
                    getTransport().getTransportInfo().getCurrentSpeed()
            )
    );
    getTransport().getLastChange().setEventedValue(
            getTransport().getInstanceId(),
            new AVTransportVariable.TransportState(TransportState.PAUSED_PLAYBACK),
            new AVTransportVariable.CurrentTransportActions(getCurrentTransportActions())
    );
}
 
Example #7
Source File: Playing.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public void onEntry() {
    log.fine("Setting transport state to PLAYING");
    getTransport().setTransportInfo(
            new TransportInfo(
                    TransportState.PLAYING,
                    getTransport().getTransportInfo().getCurrentTransportStatus(),
                    getTransport().getTransportInfo().getCurrentSpeed()
            )
    );
    getTransport().getLastChange().setEventedValue(
            getTransport().getInstanceId(),
            new AVTransportVariable.TransportState(TransportState.PLAYING),
            new AVTransportVariable.CurrentTransportActions(getCurrentTransportActions())
    );
}
 
Example #8
Source File: ZxtMediaPlayer.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public void durationChanged(int duration) {
    log.fine("Duration Changed event received: " + duration);
    synchronized (ZxtMediaPlayer.this) {
        String newValue = ModelUtil.toTimeString(duration/1000);
        currentMediaInfo = new MediaInfo(currentMediaInfo.getCurrentURI(), "",
                new UnsignedIntegerFourBytes(1), newValue, StorageMedium.NETWORK);

        getAvTransportLastChange().setEventedValue(getInstanceId(),
                new AVTransportVariable.CurrentTrackDuration(newValue),
                new AVTransportVariable.CurrentMediaDuration(newValue));
    }
}
 
Example #9
Source File: AbstractAVTransportService.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void appendCurrentState(LastChange lc, UnsignedIntegerFourBytes instanceId) throws Exception {

    MediaInfo mediaInfo = getMediaInfo(instanceId);
    TransportInfo transportInfo = getTransportInfo(instanceId);
    TransportSettings transportSettings = getTransportSettings(instanceId);
    PositionInfo positionInfo = getPositionInfo(instanceId);
    DeviceCapabilities deviceCaps = getDeviceCapabilities(instanceId);

    lc.setEventedValue(
            instanceId,
            new AVTransportVariable.AVTransportURI(URI.create(mediaInfo.getCurrentURI())),
            new AVTransportVariable.AVTransportURIMetaData(mediaInfo.getCurrentURIMetaData()),
            new AVTransportVariable.CurrentMediaDuration(mediaInfo.getMediaDuration()),
            new AVTransportVariable.CurrentPlayMode(transportSettings.getPlayMode()),
            new AVTransportVariable.CurrentRecordQualityMode(transportSettings.getRecQualityMode()),
            new AVTransportVariable.CurrentTrack(positionInfo.getTrack()),
            new AVTransportVariable.CurrentTrackDuration(positionInfo.getTrackDuration()),
            new AVTransportVariable.CurrentTrackMetaData(positionInfo.getTrackMetaData()),
            new AVTransportVariable.CurrentTrackURI(URI.create(positionInfo.getTrackURI())),
            new AVTransportVariable.CurrentTransportActions(getCurrentTransportActions(instanceId)),
            new AVTransportVariable.NextAVTransportURI(URI.create(mediaInfo.getNextURI())),
            new AVTransportVariable.NextAVTransportURIMetaData(mediaInfo.getNextURIMetaData()),
            new AVTransportVariable.NumberOfTracks(mediaInfo.getNumberOfTracks()),
            new AVTransportVariable.PossiblePlaybackStorageMedia(deviceCaps.getPlayMedia()),
            new AVTransportVariable.PossibleRecordQualityModes(deviceCaps.getRecQualityModes()),
            new AVTransportVariable.PossibleRecordStorageMedia(deviceCaps.getRecMedia()),
            new AVTransportVariable.RecordMediumWriteStatus(mediaInfo.getWriteStatus()),
            new AVTransportVariable.RecordStorageMedium(mediaInfo.getRecordMedium()),
            new AVTransportVariable.TransportPlaySpeed(transportInfo.getCurrentSpeed()),
            new AVTransportVariable.TransportState(transportInfo.getCurrentTransportState()),
            new AVTransportVariable.TransportStatus(transportInfo.getCurrentTransportStatus())
    );
}
 
Example #10
Source File: NoMediaPresent.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public void onEntry() {
    log.fine("Setting transport state to NO_MEDIA_PRESENT");
    getTransport().setTransportInfo(
            new TransportInfo(
                    TransportState.NO_MEDIA_PRESENT,
                    getTransport().getTransportInfo().getCurrentTransportStatus(),
                    getTransport().getTransportInfo().getCurrentSpeed()
            )
    );
    getTransport().getLastChange().setEventedValue(
            getTransport().getInstanceId(),
            new AVTransportVariable.TransportState(TransportState.NO_MEDIA_PRESENT),
            new AVTransportVariable.CurrentTransportActions(getCurrentTransportActions())
    );
}
 
Example #11
Source File: Stopped.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public void onEntry() {
    log.fine("Setting transport state to STOPPED");
    getTransport().setTransportInfo(
            new TransportInfo(
                    TransportState.STOPPED,
                    getTransport().getTransportInfo().getCurrentTransportStatus(),
                    getTransport().getTransportInfo().getCurrentSpeed()
            )
    );
    getTransport().getLastChange().setEventedValue(
            getTransport().getInstanceId(),
            new AVTransportVariable.TransportState(TransportState.STOPPED),
            new AVTransportVariable.CurrentTransportActions(getCurrentTransportActions())
    );
}
 
Example #12
Source File: PausedPlay.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public void onEntry() {
    log.fine("Setting transport state to PAUSED_PLAYBACK");
    getTransport().setTransportInfo(
            new TransportInfo(
                    TransportState.PAUSED_PLAYBACK,
                    getTransport().getTransportInfo().getCurrentTransportStatus(),
                    getTransport().getTransportInfo().getCurrentSpeed()
            )
    );
    getTransport().getLastChange().setEventedValue(
            getTransport().getInstanceId(),
            new AVTransportVariable.TransportState(TransportState.PAUSED_PLAYBACK),
            new AVTransportVariable.CurrentTransportActions(getCurrentTransportActions())
    );
}
 
Example #13
Source File: Playing.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public void onEntry() {
    log.fine("Setting transport state to PLAYING");
    getTransport().setTransportInfo(
            new TransportInfo(
                    TransportState.PLAYING,
                    getTransport().getTransportInfo().getCurrentTransportStatus(),
                    getTransport().getTransportInfo().getCurrentSpeed()
            )
    );
    getTransport().getLastChange().setEventedValue(
            getTransport().getInstanceId(),
            new AVTransportVariable.TransportState(TransportState.PLAYING),
            new AVTransportVariable.CurrentTransportActions(getCurrentTransportActions())
    );
}
 
Example #14
Source File: ZxtMediaPlayer.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public void durationChanged(int duration) {
    log.fine("Duration Changed event received: " + duration);
    synchronized (ZxtMediaPlayer.this) {
        String newValue = ModelUtil.toTimeString(duration/1000);
        currentMediaInfo = new MediaInfo(currentMediaInfo.getCurrentURI(), "",
                new UnsignedIntegerFourBytes(1), newValue, StorageMedium.NETWORK);

        getAvTransportLastChange().setEventedValue(getInstanceId(),
                new AVTransportVariable.CurrentTrackDuration(newValue),
                new AVTransportVariable.CurrentMediaDuration(newValue));
    }
}
 
Example #15
Source File: DLNAController.java    From Popeens-DSub with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void create(final boolean playing, final int seconds) {
	downloadService.setPlayerState(PlayerState.PREPARING);

	callback = new SubscriptionCallback(getTransportService(), 600) {
		@Override
		protected void failed(GENASubscription genaSubscription, UpnpResponse upnpResponse, Exception e, String msg) {
			Log.w(TAG, "Register subscription callback failed: " + msg, e);
		}

		@Override
		protected void established(GENASubscription genaSubscription) {
			Action seekAction = genaSubscription.getService().getAction("Seek");
			if(seekAction != null) {
				StateVariable seekMode = genaSubscription.getService().getStateVariable("A_ARG_TYPE_SeekMode");
				for(String allowedValue: seekMode.getTypeDetails().getAllowedValues()) {
					if("REL_TIME".equals(allowedValue)) {
						supportsSeek = true;
					}
				}
			}
			Action setupNextAction = genaSubscription.getService().getAction("SetNextAVTransportURI");
			if(setupNextAction != null) {
				supportsSetupNext = true;
			}

			startSong(downloadService.getCurrentPlaying(), playing, seconds);
			downloadService.postDelayed(searchDLNA, SEARCH_UPDATE_INTERVAL_SECONDS);
		}

		@Override
		protected void ended(GENASubscription genaSubscription, CancelReason cancelReason, UpnpResponse upnpResponse) {
			Log.i(TAG, "Ended subscription");
			if(cancelReason != null) {
				Log.i(TAG, "Cancel Reason: " + cancelReason.toString());
			}
			if(upnpResponse != null) {
				Log.i(TAG, "Reponse Message: " + upnpResponse.getStatusMessage());
				Log.i(TAG, "Response Details: " + upnpResponse.getResponseDetails());
			}
		}

		@Override
		protected void eventReceived(GENASubscription genaSubscription) {
			Map<String, StateVariableValue> m = genaSubscription.getCurrentValues();
			try {
				String lastChangeText = m.get("LastChange").toString();
				lastChangeText = lastChangeText.replace(",X_DLNA_SeekTime","").replace(",X_DLNA_SeekByte", "");
				LastChange lastChange = new LastChange(new AVTransportLastChangeParser(), lastChangeText);

				if (lastChange.getEventedValue(0, AVTransportVariable.TransportState.class) == null) {
					return;
				}

				switch (lastChange.getEventedValue(0, AVTransportVariable.TransportState.class).getValue()) {
					case PLAYING:
						downloadService.setPlayerState(PlayerState.STARTED);
						break;
					case PAUSED_PLAYBACK:
						downloadService.setPlayerState(PlayerState.PAUSED);
						break;
					case STOPPED:
						boolean failed = false;
						for(StateVariableValue val: m.values()) {
							if(val.toString().indexOf("TransportStatus val=\"ERROR_OCCURRED\"") != -1) {
								Log.w(TAG, "Failed to load with event: " + val.toString());
								failed = true;
							}
						}

						if(failed) {
							failedLoad();
						} else if(downloadService.getPlayerState() == PlayerState.STARTED) {
							// Played until the end
							downloadService.onSongCompleted();
						} else {
							downloadService.setPlayerState(PlayerState.STOPPED);
						}
						break;
					case TRANSITIONING:
						downloadService.setPlayerState(PlayerState.PREPARING);
						break;
					case NO_MEDIA_PRESENT:
						downloadService.setPlayerState(PlayerState.IDLE);
						break;
					default:
				}
			}
			catch (Exception e) {
				Log.w(TAG, "Failed to parse UPNP event", e);
			}
		}

		@Override
		protected void eventsMissed(GENASubscription genaSubscription, int i) {
			Log.w(TAG, "Event missed: " + i);
		}
	};
	controlPoint.execute(callback);
}