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

The following examples show how to use org.fourthline.cling.support.model.TransportState. These examples are extracted from open source projects. 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 Project: TVRemoteIME   Author: kingthy   File: ZxtMediaPlayer.java    License: 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 Project: DroidDLNA   Author: offbye   File: ZxtMediaPlayer.java    License: 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 Project: TVRemoteIME   Author: kingthy   File: AbstractAVTransportService.java    License: 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 Project: TVRemoteIME   Author: kingthy   File: NoMediaPresent.java    License: 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 Project: TVRemoteIME   Author: kingthy   File: Stopped.java    License: 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 Project: TVRemoteIME   Author: kingthy   File: PausedPlay.java    License: 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 Project: TVRemoteIME   Author: kingthy   File: Playing.java    License: 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 Project: TVRemoteIME   Author: kingthy   File: ZxtMediaPlayer.java    License: 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 #9
Source Project: TVRemoteIME   Author: kingthy   File: ZxtMediaPlayers.java    License: 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 #10
Source Project: TVRemoteIME   Author: kingthy   File: ZxtMediaRenderer.java    License: 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 #11
Source Project: BeyondUPnP   Author: kevinshine   File: MediaPlayerController.java    License: 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 #12
Source Project: DroidDLNA   Author: offbye   File: AbstractAVTransportService.java    License: 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 #13
Source Project: DroidDLNA   Author: offbye   File: NoMediaPresent.java    License: 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 #14
Source Project: DroidDLNA   Author: offbye   File: Stopped.java    License: 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 #15
Source Project: DroidDLNA   Author: offbye   File: PausedPlay.java    License: 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 #16
Source Project: DroidDLNA   Author: offbye   File: Playing.java    License: 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 #17
Source Project: DroidDLNA   Author: offbye   File: ZxtMediaPlayer.java    License: 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 #18
Source Project: DroidDLNA   Author: offbye   File: ZxtMediaPlayers.java    License: 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 #19
Source Project: DroidDLNA   Author: offbye   File: ZxtMediaRenderer.java    License: 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 #20
Source Project: TVRemoteIME   Author: kingthy   File: ZxtMediaPlayer.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void pause() {
    transportStateChanged(TransportState.PAUSED_PLAYBACK);
}
 
Example #21
Source Project: TVRemoteIME   Author: kingthy   File: ZxtMediaPlayer.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void start() {
    transportStateChanged(TransportState.PLAYING);
}
 
Example #22
Source Project: TVRemoteIME   Author: kingthy   File: ZxtMediaPlayer.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void stop() {
    transportStateChanged(TransportState.STOPPED);
}
 
Example #23
Source Project: TVRemoteIME   Author: kingthy   File: ZxtMediaPlayer.java    License: 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 Project: BeyondUPnP   Author: kevinshine   File: MediaPlayerController.java    License: Apache License 2.0 4 votes vote down vote up
public TransportState getCurrentState() {
    return mCurrentState;
}
 
Example #25
Source Project: BeyondUPnP   Author: kevinshine   File: MediaPlayerController.java    License: Apache License 2.0 4 votes vote down vote up
public void setCurrentState(TransportState currentState) {
    if (this.mCurrentState != currentState) {
        this.mCurrentState = currentState;
    }
}
 
Example #26
Source Project: DroidDLNA   Author: offbye   File: ZxtMediaPlayer.java    License: GNU General Public License v3.0 4 votes vote down vote up
public void pause() {
    transportStateChanged(TransportState.PAUSED_PLAYBACK);
}
 
Example #27
Source Project: DroidDLNA   Author: offbye   File: ZxtMediaPlayer.java    License: GNU General Public License v3.0 4 votes vote down vote up
public void start() {
    transportStateChanged(TransportState.PLAYING);
}
 
Example #28
Source Project: DroidDLNA   Author: offbye   File: ZxtMediaPlayer.java    License: GNU General Public License v3.0 4 votes vote down vote up
public void stop() {
    transportStateChanged(TransportState.STOPPED);
}
 
Example #29
Source Project: DroidDLNA   Author: offbye   File: ZxtMediaPlayer.java    License: 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();
}