org.fourthline.cling.support.model.TransportState Java Examples

The following examples show how to use org.fourthline.cling.support.model.TransportState. 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 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 #2
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 #3
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 #4
Source File: ZxtMediaRenderer.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
synchronized public void stopAllMediaPlayers() {
        for (ZxtMediaPlayer mediaPlayer : mediaPlayers.values()) {
            TransportState state =
                mediaPlayer.getCurrentTransportInfo().getCurrentTransportState();
            if (!state.equals(TransportState.NO_MEDIA_PRESENT) ||
                    state.equals(TransportState.STOPPED)) {
                Log.i(TAG, "Stopping player instance: " + mediaPlayer.getInstanceId());
//                mediaPlayer.stop();
            }
        }
    }
 
Example #5
Source File: ZxtMediaPlayers.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public ZxtMediaPlayers(int numberOfPlayers,
                       Context context,
                       LastChange avTransportLastChange,
                       LastChange renderingControlLastChange) {
    super(numberOfPlayers);
    this.mContext = context;
    this.avTransportLastChange = avTransportLastChange;
    this.renderingControlLastChange = renderingControlLastChange;

    for (int i = 0; i < numberOfPlayers; i++) {

        ZxtMediaPlayer player =
                new ZxtMediaPlayer(
                        new UnsignedIntegerFourBytes(i),
                        mContext,
                        avTransportLastChange,
                        renderingControlLastChange
                ) {
                    @Override
                    protected void transportStateChanged(TransportState newState) {
                        super.transportStateChanged(newState);
                        if (newState.equals(TransportState.PLAYING)) {
                            onPlay(this);
                        } else if (newState.equals(TransportState.STOPPED)) {
                            onStop(this);
                        }
                    }
                };
        put(player.getInstanceId(), player);
    }
}
 
Example #6
Source File: ZxtMediaPlayer.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
synchronized public TransportAction[] getCurrentTransportActions() {
    TransportState state = currentTransportInfo.getCurrentTransportState();
    TransportAction[] actions;

    switch (state) {
        case STOPPED:
            actions = new TransportAction[]{
                    TransportAction.Play
            };
            break;
        case PLAYING:
            actions = new TransportAction[]{
                    TransportAction.Stop,
                    TransportAction.Pause,
                    TransportAction.Seek
            };
            break;
        case PAUSED_PLAYBACK:
            actions = new TransportAction[]{
                    TransportAction.Stop,
                    TransportAction.Pause,
                    TransportAction.Seek,
                    TransportAction.Play
            };
            break;
        default:
            actions = null;
    }
    return actions;
}
 
Example #7
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 #8
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 #9
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 #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: 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 #12
Source File: MediaPlayerController.java    From BeyondUPnP with Apache License 2.0 5 votes vote down vote up
public void startUpdateSeekBar() throws InterruptedException, ExecutionException {
    Log.i(TAG, "Execute startUpdateSeekBar");
    if (this.mCurrentState == TransportState.PLAYING && isPaused) {
        synchronized (mPlaybackLock) {
            isPaused = false;
            Log.i(TAG, "Resume seekbar sync thread.");
            mPlaybackLock.notifyAll();
        }
    }
}
 
Example #13
Source File: ZxtMediaPlayer.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
synchronized public TransportAction[] getCurrentTransportActions() {
    TransportState state = currentTransportInfo.getCurrentTransportState();
    TransportAction[] actions;

    switch (state) {
        case STOPPED:
            actions = new TransportAction[]{
                    TransportAction.Play
            };
            break;
        case PLAYING:
            actions = new TransportAction[]{
                    TransportAction.Stop,
                    TransportAction.Pause,
                    TransportAction.Seek
            };
            break;
        case PAUSED_PLAYBACK:
            actions = new TransportAction[]{
                    TransportAction.Stop,
                    TransportAction.Pause,
                    TransportAction.Seek,
                    TransportAction.Play
            };
            break;
        default:
            actions = null;
    }
    return actions;
}
 
Example #14
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 #15
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 #16
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 #17
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 #18
Source File: ZxtMediaRenderer.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
synchronized public void stopAllMediaPlayers() {
        for (ZxtMediaPlayer mediaPlayer : mediaPlayers.values()) {
            TransportState state =
                mediaPlayer.getCurrentTransportInfo().getCurrentTransportState();
            if (!state.equals(TransportState.NO_MEDIA_PRESENT) ||
                    state.equals(TransportState.STOPPED)) {
                Log.i(TAG, "Stopping player instance: " + mediaPlayer.getInstanceId());
//                mediaPlayer.stop();
            }
        }
    }
 
Example #19
Source File: ZxtMediaPlayers.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public ZxtMediaPlayers(int numberOfPlayers,
                       Context context,
                       LastChange avTransportLastChange,
                       LastChange renderingControlLastChange) {
    super(numberOfPlayers);
    this.mContext = context;
    this.avTransportLastChange = avTransportLastChange;
    this.renderingControlLastChange = renderingControlLastChange;

    for (int i = 0; i < numberOfPlayers; i++) {

        ZxtMediaPlayer player =
                new ZxtMediaPlayer(
                        new UnsignedIntegerFourBytes(i),
                        mContext,
                        avTransportLastChange,
                        renderingControlLastChange
                ) {
                    @Override
                    protected void transportStateChanged(TransportState newState) {
                        super.transportStateChanged(newState);
                        if (newState.equals(TransportState.PLAYING)) {
                            onPlay(this);
                        } else if (newState.equals(TransportState.STOPPED)) {
                            onStop(this);
                        }
                    }
                };
        put(player.getInstanceId(), player);
    }
}
 
Example #20
Source File: ZxtMediaPlayer.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public void start() {
    transportStateChanged(TransportState.PLAYING);
}
 
Example #21
Source File: ZxtMediaPlayer.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public void pause() {
    transportStateChanged(TransportState.PAUSED_PLAYBACK);
}
 
Example #22
Source File: ZxtMediaPlayer.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public void stop() {
    transportStateChanged(TransportState.STOPPED);
}
 
Example #23
Source File: ZxtMediaPlayer.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public void endOfMedia() {
    log.fine("End Of Media event received, stopping media player backend");
    transportStateChanged(TransportState.NO_MEDIA_PRESENT);
    //GstMediaPlayer.this.stop();
}
 
Example #24
Source File: ZxtMediaPlayer.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public void pause() {
    transportStateChanged(TransportState.PAUSED_PLAYBACK);
}
 
Example #25
Source File: ZxtMediaPlayer.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public void start() {
    transportStateChanged(TransportState.PLAYING);
}
 
Example #26
Source File: ZxtMediaPlayer.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public void stop() {
    transportStateChanged(TransportState.STOPPED);
}
 
Example #27
Source File: ZxtMediaPlayer.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public void endOfMedia() {
    log.fine("End Of Media event received, stopping media player backend");
    transportStateChanged(TransportState.NO_MEDIA_PRESENT);
    //GstMediaPlayer.this.stop();
}
 
Example #28
Source File: MediaPlayerController.java    From BeyondUPnP with Apache License 2.0 4 votes vote down vote up
public void setCurrentState(TransportState currentState) {
    if (this.mCurrentState != currentState) {
        this.mCurrentState = currentState;
    }
}
 
Example #29
Source File: MediaPlayerController.java    From BeyondUPnP with Apache License 2.0 4 votes vote down vote up
public TransportState getCurrentState() {
    return mCurrentState;
}