com.google.android.media.tv.companionlibrary.model.RecordedProgram Java Examples

The following examples show how to use com.google.android.media.tv.companionlibrary.model.RecordedProgram. 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: BaseTvInputService.java    From androidtv-sample-inputs with Apache License 2.0 6 votes vote down vote up
@Override
public boolean handleMessage(Message msg) {
    switch (msg.what) {
        case MSG_PLAY_CONTENT:
            mCurrentProgram = (Program) msg.obj;
            playCurrentContent();
            return true;
        case MSG_PLAY_AD:
            return insertAd((Advertisement) msg.obj);
        case MSG_PLAY_RECORDED_CONTENT:
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                mPlayingRecordedProgram = true;
                mRecordedProgram = (RecordedProgram) msg.obj;
                playRecordedContent();
            }
            return true;
    }
    return false;
}
 
Example #2
Source File: RichTvInputService.java    From androidtv-sample-inputs with Apache License 2.0 6 votes vote down vote up
@Override
public void onStopRecording(Program programToRecord) {
    if (DEBUG) {
        Log.d(TAG, "onStopRecording");
    }
    // In this sample app, since all of the content is VOD, the video URL is stored.
    // If the video was live, the start and stop times should be noted using
    // RecordedProgram.Builder.setStartTimeUtcMillis and .setEndTimeUtcMillis.
    // The recordingstart time will be saved in the InternalProviderData.
    // Additionally, the stream should be recorded and saved as
    // a new file.
    long currentTime = System.currentTimeMillis();
    InternalProviderData internalProviderData = programToRecord.getInternalProviderData();
    internalProviderData.setRecordingStartTime(mStartTimeMs);
    RecordedProgram recordedProgram = new RecordedProgram.Builder(programToRecord)
                .setInputId(mInputId)
                .setRecordingDataUri(
                        programToRecord.getInternalProviderData().getVideoUrl())
                .setRecordingDurationMillis(currentTime - mStartTimeMs)
                .setInternalProviderData(internalProviderData)
                .build();
    notifyRecordingStopped(recordedProgram);
}
 
Example #3
Source File: BaseTvInputService.java    From xipl with Apache License 2.0 6 votes vote down vote up
@Override
public boolean handleMessage(Message msg) {
    switch (msg.what) {
        case MSG_PLAY_CONTENT:
            mCurrentProgram = (Program) msg.obj;
            playCurrentContent();
            return true;
        case MSG_PLAY_AD:
            return insertAd((Advertisement) msg.obj);
        case MSG_PLAY_RECORDED_CONTENT:
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                mPlayingRecordedProgram = true;
                mRecordedProgram = (RecordedProgram) msg.obj;
                playRecordedContent();
            }
            return true;
    }
    return false;
}
 
Example #4
Source File: RichTvInputService.java    From androidtv-sample-inputs with Apache License 2.0 5 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.N)
public boolean onPlayRecordedProgram(RecordedProgram recordedProgram) {
    createPlayer(recordedProgram.getInternalProviderData().getVideoType(),
            Uri.parse(recordedProgram.getInternalProviderData().getVideoUrl()));

    long recordingStartTime = recordedProgram.getInternalProviderData()
            .getRecordedProgramStartTime();
    mPlayer.seekTo(recordingStartTime - recordedProgram.getStartTimeUtcMillis());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        notifyTimeShiftStatusChanged(TvInputManager.TIME_SHIFT_STATUS_AVAILABLE);
    }
    mPlayer.setPlayWhenReady(true);
    return true;
}
 
Example #5
Source File: TestTvInputService.java    From androidtv-sample-inputs with Apache License 2.0 5 votes vote down vote up
@Override
public void onStopRecordingChannel(Channel channelToRecord) {
    mIsRecording = false;
    // Add a sample program into our DVR
    notifyRecordingStopped(new RecordedProgram.Builder()
            .setInputId(mInputId)
            .setTitle("That Gmail Blue Video")
            .setRecordingDataUri(TestJobService.GMAIL_BLUE_VIDEO_URL)
            .setStartTimeUtcMillis(System.currentTimeMillis())
            .setEndTimeUtcMillis(System.currentTimeMillis() + 1000 * 60 * 60)
            .build());
}
 
Example #6
Source File: TestTvInputService.java    From androidtv-sample-inputs with Apache License 2.0 5 votes vote down vote up
@Override
public void onStopRecording(Program programToRecord) {
    mIsRecording = false;
    // Add a sample program into our DVR
    notifyRecordingStopped(new RecordedProgram.Builder()
            .setInputId(mInputId)
            .setTitle("That Gmail Blue Video")
            .setRecordingDataUri(TestJobService.GMAIL_BLUE_VIDEO_URL)
            .setStartTimeUtcMillis(System.currentTimeMillis())
            .setEndTimeUtcMillis(System.currentTimeMillis() + 1000 * 60 * 60)
            .build());
}
 
Example #7
Source File: TestTvInputService.java    From androidtv-sample-inputs with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onPlayRecordedProgram(RecordedProgram recordedProgram) {
    if (recordedProgram == null) {
        return false;
    } else {
        return playMediaUrl(recordedProgram.getRecordingDataUri());
    }
}
 
Example #8
Source File: BaseTvInputService.java    From androidtv-sample-inputs with Apache License 2.0 5 votes vote down vote up
/**
 * Notify the TV app that the recording has ended.
 *
 * @param recordedProgram The program that was recorded and should be saved.
 */
public void notifyRecordingStopped(final RecordedProgram recordedProgram) {
    mDbHandler.post(
            new Runnable() {
                @Override
                public void run() {
                    Uri recordedProgramUri =
                            mContext.getContentResolver()
                                    .insert(
                                            TvContract.RecordedPrograms.CONTENT_URI,
                                            recordedProgram.toContentValues());
                    notifyRecordingStopped(recordedProgramUri);
                }
            });
}
 
Example #9
Source File: BaseTvInputService.java    From androidtv-sample-inputs with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    ContentResolver contentResolver = mContext.getContentResolver();
    Cursor cursor =
            contentResolver.query(
                    mRecordedProgramUri, RecordedProgram.PROJECTION, null, null, null);
    if (cursor == null) {
        // The recorded program does not exist.
        notifyVideoUnavailable(TvInputManager.VIDEO_UNAVAILABLE_REASON_UNKNOWN);
    } else {
        if (cursor.moveToNext()) {
            RecordedProgram recordedProgram = RecordedProgram.fromCursor(cursor);
            if (DEBUG) {
                Log.d(TAG, "Play program " + recordedProgram.getTitle());
                Log.d(TAG, recordedProgram.getRecordingDataUri());
            }
            if (recordedProgram == null) {
                Log.e(
                        TAG,
                        "RecordedProgram at "
                                + mRecordedProgramUri
                                + " does not "
                                + "exist");
                notifyVideoUnavailable(TvInputManager.VIDEO_UNAVAILABLE_REASON_UNKNOWN);
            }
            mHandler.removeMessages(MSG_PLAY_RECORDED_CONTENT);
            mHandler.obtainMessage(MSG_PLAY_RECORDED_CONTENT, recordedProgram)
                    .sendToTarget();
        }
    }
}
 
Example #10
Source File: CumulusTvTifService.java    From CumulusTV with MIT License 5 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.N)
public boolean onPlayRecordedProgram(RecordedProgram recordedProgram) {
    createPlayer(recordedProgram.getInternalProviderData().getVideoType(),
            Uri.parse(recordedProgram.getInternalProviderData().getVideoUrl()));

    long recordingStartTime = recordedProgram.getInternalProviderData()
            .getRecordedProgramStartTime();
    mPlayer.seekTo(recordingStartTime - recordedProgram.getStartTimeUtcMillis());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        notifyTimeShiftStatusChanged(TvInputManager.TIME_SHIFT_STATUS_AVAILABLE);
    }
    mPlayer.play();
    notifyVideoAvailable();
    return true;
}
 
Example #11
Source File: TestTvInputService.java    From xipl with Apache License 2.0 5 votes vote down vote up
@Override
public void onStopRecordingChannel(Channel channelToRecord) {
    mIsRecording = false;
    // Add a sample program into our DVR
    notifyRecordingStopped(new RecordedProgram.Builder()
            .setInputId(mInputId)
            .setTitle("That Gmail Blue Video")
            .setRecordingDataUri(TestJobService.GMAIL_BLUE_VIDEO_URL)
            .setStartTimeUtcMillis(System.currentTimeMillis())
            .setEndTimeUtcMillis(System.currentTimeMillis() + 1000 * 60 * 60)
            .build());
}
 
Example #12
Source File: TestTvInputService.java    From xipl with Apache License 2.0 5 votes vote down vote up
@Override
public void onStopRecording(Program programToRecord) {
    mIsRecording = false;
    // Add a sample program into our DVR
    notifyRecordingStopped(new RecordedProgram.Builder()
            .setInputId(mInputId)
            .setTitle("That Gmail Blue Video")
            .setRecordingDataUri(TestJobService.GMAIL_BLUE_VIDEO_URL)
            .setStartTimeUtcMillis(System.currentTimeMillis())
            .setEndTimeUtcMillis(System.currentTimeMillis() + 1000 * 60 * 60)
            .build());
}
 
Example #13
Source File: TestTvInputService.java    From xipl with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onPlayRecordedProgram(RecordedProgram recordedProgram) {
    if (recordedProgram == null) {
        return false;
    } else {
        return playMediaUrl(recordedProgram.getRecordingDataUri());
    }
}
 
Example #14
Source File: BaseTvInputService.java    From xipl with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    ContentResolver contentResolver = mContext.getContentResolver();
    Cursor cursor =
            contentResolver.query(
                    mRecordedProgramUri, RecordedProgram.PROJECTION, null, null, null);
    if (cursor == null) {
        // The recorded program does not exist.
        notifyVideoUnavailable(TvInputManager.VIDEO_UNAVAILABLE_REASON_UNKNOWN);
    } else {
        if (cursor.moveToNext()) {
            RecordedProgram recordedProgram = RecordedProgram.fromCursor(cursor);
            if (DEBUG) {
                Log.d(TAG, "Play program " + recordedProgram.getTitle());
                Log.d(TAG, recordedProgram.getRecordingDataUri());
            }
            if (recordedProgram == null) {
                Log.e(
                        TAG,
                        "RecordedProgram at "
                                + mRecordedProgramUri
                                + " does not "
                                + "exist");
                notifyVideoUnavailable(TvInputManager.VIDEO_UNAVAILABLE_REASON_UNKNOWN);
            }
            mHandler.removeMessages(MSG_PLAY_RECORDED_CONTENT);
            mHandler.obtainMessage(MSG_PLAY_RECORDED_CONTENT, recordedProgram)
                    .sendToTarget();
        }
    }
}
 
Example #15
Source File: ProviderTvInputService.java    From xipl with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onPlayRecordedProgram(RecordedProgram recordedProgram) {
    return (false);
}
 
Example #16
Source File: BaseTvInputService.java    From xipl with Apache License 2.0 4 votes vote down vote up
/**
 * Notify the TV app that the recording has ended.
 *
 * @param recordedProgram The program that was recorded and should be saved.
 */
public void notifyRecordingStopped(final RecordedProgram recordedProgram) {
    mDbHandler.post(
            new Runnable() {
                @Override
                public void run() {
                    Uri recordedProgramUri =
                            mContext.getContentResolver()
                                    .insert(
                                            TvContract.RecordedPrograms.CONTENT_URI,
                                            recordedProgram.toContentValues());
                    notifyRecordingStopped(recordedProgramUri);
                }
            });
}
 
Example #17
Source File: BaseTvInputService.java    From androidtv-sample-inputs with Apache License 2.0 2 votes vote down vote up
/**
 * This method is called when a particular recorded program is to begin playing. If the
 * program does not exist, the parameter will be {@code null}.
 *
 * @param recordedProgram The program that is set to be playing for a the currently tuned
 *     channel.
 * @return Whether playing this program was successful
 */
public abstract boolean onPlayRecordedProgram(RecordedProgram recordedProgram);
 
Example #18
Source File: BaseTvInputService.java    From xipl with Apache License 2.0 2 votes vote down vote up
/**
 * This method is called when a particular recorded program is to begin playing. If the
 * program does not exist, the parameter will be {@code null}.
 *
 * @param recordedProgram The program that is set to be playing for a the currently tuned
 *     channel.
 * @return Whether playing this program was successful
 */
public abstract boolean onPlayRecordedProgram(RecordedProgram recordedProgram);