Java Code Examples for android.media.tv.TvInputManager#TIME_SHIFT_INVALID_TIME
The following examples show how to use
android.media.tv.TvInputManager#TIME_SHIFT_INVALID_TIME .
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 |
@Override public void run() { ContentResolver resolver = mContext.getContentResolver(); Program program = null; long timeShiftedDifference = System.currentTimeMillis() - mTimeShiftedPlaybackPosition; if (mTimeShiftedPlaybackPosition != TvInputManager.TIME_SHIFT_INVALID_TIME && timeShiftedDifference > TIME_SHIFTED_MINIMUM_DIFFERENCE_MILLIS) { program = ModelUtils.getNextProgram(resolver, mChannelUri, mCurrentProgram); } else { mTimeShiftedPlaybackPosition = TvInputManager.TIME_SHIFT_INVALID_TIME; program = ModelUtils.getCurrentProgram(resolver, mChannelUri); } mHandler.removeMessages(MSG_PLAY_CONTENT); mHandler.obtainMessage(MSG_PLAY_CONTENT, program).sendToTarget(); }
Example 2
Source File: BaseTvInputService.java From xipl with Apache License 2.0 | 6 votes |
@Override public void run() { ContentResolver resolver = mContext.getContentResolver(); Program program = null; long timeShiftedDifference = System.currentTimeMillis() - mTimeShiftedPlaybackPosition; if (mTimeShiftedPlaybackPosition != TvInputManager.TIME_SHIFT_INVALID_TIME && timeShiftedDifference > TIME_SHIFTED_MINIMUM_DIFFERENCE_MILLIS) { program = ModelUtils.getNextProgram(resolver, mChannelUri, mCurrentProgram); } else { mTimeShiftedPlaybackPosition = TvInputManager.TIME_SHIFT_INVALID_TIME; program = ModelUtils.getCurrentProgram(resolver, mChannelUri); } mHandler.removeMessages(MSG_PLAY_CONTENT); mHandler.obtainMessage(MSG_PLAY_CONTENT, program).sendToTarget(); }
Example 3
Source File: BaseTvInputService.java From androidtv-sample-inputs with Apache License 2.0 | 6 votes |
@Override public boolean onTune(Uri channelUri) { mNeedToCheckChannelAd = true; notifyVideoUnavailable(TvInputManager.VIDEO_UNAVAILABLE_REASON_TUNING); mChannelUri = channelUri; long channelId = ContentUris.parseId(channelUri); mCurrentChannel = mChannelMap.get(channelId); mTimeShiftedPlaybackPosition = TvInputManager.TIME_SHIFT_INVALID_TIME; // Release Ads assets releaseAdController(); mHandler.removeMessages(MSG_PLAY_AD); if (mDbHandler != null) { mUnblockedRatingSet.clear(); mDbHandler.removeCallbacks(mGetCurrentProgramRunnable); mGetCurrentProgramRunnable = new GetCurrentProgramRunnable(mChannelUri); mDbHandler.post(mGetCurrentProgramRunnable); } return true; }
Example 4
Source File: SimpleSessionImpl.java From ChannelSurfer with MIT License | 5 votes |
@Override public long onTimeShiftGetCurrentPosition() { if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (tvInputProvider instanceof TimeShiftable) { return ((TimeShiftable) tvInputProvider).mediaGetCurrentMs(); } else { return TvInputManager.TIME_SHIFT_INVALID_TIME; } } else { return -1; } }
Example 5
Source File: BaseTvInputService.java From androidtv-sample-inputs with Apache License 2.0 | 5 votes |
private boolean blockContentIfNeeded() { if (mCurrentContentRatingSet == null || !mTvInputManager.isParentalControlsEnabled()) { // Content rating is invalid so we don't need to block anymore. // Unblock content here explicitly to resume playback. unblockContent(null); return true; } // Check each content rating that the program has. TvContentRating blockedRating = null; for (TvContentRating contentRating : mCurrentContentRatingSet) { if (mTvInputManager.isRatingBlocked(contentRating) && !mUnblockedRatingSet.contains(contentRating)) { // This should be blocked. blockedRating = contentRating; } } if (blockedRating == null) { // Content rating is null so we don't need to block anymore. // Unblock content here explicitly to resume playback. unblockContent(null); return true; } mLastBlockedRating = blockedRating; // Children restricted content might be blocked by TV app as well, // but TIS should do its best not to show any single frame of blocked content. onBlockContent(blockedRating); notifyContentBlocked(blockedRating); if (mTimeShiftedPlaybackPosition != TvInputManager.TIME_SHIFT_INVALID_TIME) { onTimeShiftPause(); } return false; }
Example 6
Source File: BaseTvInputService.java From androidtv-sample-inputs with Apache License 2.0 | 5 votes |
private boolean insertAd(Advertisement ad) { if (DEBUG) { Log.d(TAG, "Insert an ad"); } // If timeshifting, do not play the ad. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { long timeShiftedDifference = System.currentTimeMillis() - mTimeShiftedPlaybackPosition; if (mTimeShiftedPlaybackPosition != TvInputManager.TIME_SHIFT_INVALID_TIME && timeShiftedDifference > TIME_SHIFTED_MINIMUM_DIFFERENCE_MILLIS) { mElapsedAdsTime += ad.getStopTimeUtcMillis() - ad.getStartTimeUtcMillis(); mTimeShiftedPlaybackPosition = mElapsedProgramTime + mElapsedAdsTime + mCurrentProgram.getStartTimeUtcMillis(); scheduleNextAd(); scheduleNextProgram(); // If timeshifting, but skipping the ad would actually put us ahead of // live streaming, then readjust to the live stream position. if (mTimeShiftedPlaybackPosition > System.currentTimeMillis()) { mTimeShiftedPlaybackPosition = TvInputManager.TIME_SHIFT_INVALID_TIME; playCurrentContent(); } return false; } } releaseAdController(); mAdController = new AdController(mContext); mAdController.requestAds(ad.getRequestUrl(), new AdControllerCallbackImpl(ad)); return true; }
Example 7
Source File: BaseTvInputService.java From androidtv-sample-inputs with Apache License 2.0 | 5 votes |
private long getCurrentTime() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { long timeShiftedDifference = System.currentTimeMillis() - mTimeShiftedPlaybackPosition; if (mTimeShiftedPlaybackPosition != TvInputManager.TIME_SHIFT_INVALID_TIME && timeShiftedDifference > TIME_SHIFTED_MINIMUM_DIFFERENCE_MILLIS) { return mTimeShiftedPlaybackPosition; } } mTimeShiftedPlaybackPosition = TvInputManager.TIME_SHIFT_INVALID_TIME; return System.currentTimeMillis(); }
Example 8
Source File: BaseTvInputService.java From androidtv-sample-inputs with Apache License 2.0 | 5 votes |
@RequiresApi(api = Build.VERSION_CODES.M) @Override public long onTimeShiftGetStartPosition() { if (mCurrentProgram != null) { if (mPlayingRecordedProgram) { return mRecordedPlaybackStartTime; } else { return mCurrentProgram.getStartTimeUtcMillis(); } } return TvInputManager.TIME_SHIFT_INVALID_TIME; }
Example 9
Source File: CumulusTvTifService.java From CumulusTV with MIT License | 5 votes |
@TargetApi(Build.VERSION_CODES.M) @RequiresApi(api = Build.VERSION_CODES.M) @Override public long onTimeShiftGetCurrentPosition() { if (mPlayer == null) { return TvInputManager.TIME_SHIFT_INVALID_TIME; } long currentMs = tuneTime + mPlayer.getCurrentPosition(); if (DEBUG) { Log.d(TAG, currentMs + " " + onTimeShiftGetStartPosition() + " start position"); Log.d(TAG, (currentMs - onTimeShiftGetStartPosition()) + " diff start position"); } return currentMs; }
Example 10
Source File: ExoPlayerInputProvider.java From ChannelSurfer with MIT License | 5 votes |
@Override public long mediaGetStartMs() { if(simpleSession.lastTune == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) return TvInputManager.TIME_SHIFT_INVALID_TIME; else if(simpleSession.lastTune == null) { simpleSession.lastTune = new Date(); } return simpleSession.lastTune.getTime(); }
Example 11
Source File: BaseTvInputService.java From xipl with Apache License 2.0 | 5 votes |
@Override public boolean onTune(Uri channelUri) { mNeedToCheckChannelAd = true; notifyVideoUnavailable(TvInputManager.VIDEO_UNAVAILABLE_REASON_TUNING); mChannelUri = channelUri; long channelId = ContentUris.parseId(channelUri); if (mChannelMap != null) { mCurrentChannel = mChannelMap.get(channelId); } mTimeShiftedPlaybackPosition = TvInputManager.TIME_SHIFT_INVALID_TIME; // Release Ads assets releaseAdController(); mHandler.removeMessages(MSG_PLAY_AD); if (mDbHandler != null) { mUnblockedRatingSet.clear(); mDbHandler.removeCallbacks(mGetCurrentProgramRunnable); mGetCurrentProgramRunnable = new GetCurrentProgramRunnable(mChannelUri); mDbHandler.post(mGetCurrentProgramRunnable); } return true; }
Example 12
Source File: SimpleSessionImpl.java From ChannelSurfer with MIT License | 5 votes |
@Override public long onTimeShiftGetStartPosition() { if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (tvInputProvider instanceof TimeShiftable) { return ((TimeShiftable) tvInputProvider).mediaGetStartMs(); } else { return TvInputManager.TIME_SHIFT_INVALID_TIME; } } else { return -1; } }
Example 13
Source File: MediaPlayerInputProvider.java From ChannelSurfer with MIT License | 5 votes |
@Override public long mediaGetStartMs() { if(simpleSession.lastTune == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) return TvInputManager.TIME_SHIFT_INVALID_TIME; else if(simpleSession.lastTune == null) return -1; return simpleSession.lastTune.getTime(); }
Example 14
Source File: BaseTvInputService.java From xipl with Apache License 2.0 | 5 votes |
private boolean blockContentIfNeeded() { if (mCurrentContentRatingSet == null || !mTvInputManager.isParentalControlsEnabled()) { // Content rating is invalid so we don't need to block anymore. // Unblock content here explicitly to resume playback. unblockContent(null); return true; } // Check each content rating that the program has. TvContentRating blockedRating = null; for (TvContentRating contentRating : mCurrentContentRatingSet) { if (mTvInputManager.isRatingBlocked(contentRating) && !mUnblockedRatingSet.contains(contentRating)) { // This should be blocked. blockedRating = contentRating; } } if (blockedRating == null) { // Content rating is null so we don't need to block anymore. // Unblock content here explicitly to resume playback. unblockContent(null); return true; } mLastBlockedRating = blockedRating; // Children restricted content might be blocked by TV app as well, // but TIS should do its best not to show any single frame of blocked content. onBlockContent(blockedRating); notifyContentBlocked(blockedRating); if (mTimeShiftedPlaybackPosition != TvInputManager.TIME_SHIFT_INVALID_TIME) { onTimeShiftPause(); } return false; }
Example 15
Source File: BaseTvInputService.java From xipl with Apache License 2.0 | 5 votes |
private boolean insertAd(Advertisement ad) { if (DEBUG) { Log.d(TAG, "Insert an ad"); } // If timeshifting, do not play the ad. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { long timeShiftedDifference = System.currentTimeMillis() - mTimeShiftedPlaybackPosition; if (mTimeShiftedPlaybackPosition != TvInputManager.TIME_SHIFT_INVALID_TIME && timeShiftedDifference > TIME_SHIFTED_MINIMUM_DIFFERENCE_MILLIS) { mElapsedAdsTime += ad.getStopTimeUtcMillis() - ad.getStartTimeUtcMillis(); mTimeShiftedPlaybackPosition = mElapsedProgramTime + mElapsedAdsTime + mCurrentProgram.getStartTimeUtcMillis(); scheduleNextAd(); scheduleNextProgram(); // If timeshifting, but skipping the ad would actually put us ahead of // live streaming, then readjust to the live stream position. if (mTimeShiftedPlaybackPosition > System.currentTimeMillis()) { mTimeShiftedPlaybackPosition = TvInputManager.TIME_SHIFT_INVALID_TIME; playCurrentContent(); } return false; } } releaseAdController(); mAdController = new AdController(mContext); mAdController.requestAds(ad.getRequestUrl(), new AdControllerCallbackImpl(ad)); return true; }
Example 16
Source File: BaseTvInputService.java From xipl with Apache License 2.0 | 5 votes |
private long getCurrentTime() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { long timeShiftedDifference = System.currentTimeMillis() - mTimeShiftedPlaybackPosition; if (mTimeShiftedPlaybackPosition != TvInputManager.TIME_SHIFT_INVALID_TIME && timeShiftedDifference > TIME_SHIFTED_MINIMUM_DIFFERENCE_MILLIS) { return mTimeShiftedPlaybackPosition; } } mTimeShiftedPlaybackPosition = TvInputManager.TIME_SHIFT_INVALID_TIME; return System.currentTimeMillis(); }
Example 17
Source File: BaseTvInputService.java From xipl with Apache License 2.0 | 5 votes |
@RequiresApi(api = Build.VERSION_CODES.M) @Override public long onTimeShiftGetStartPosition() { if (mCurrentProgram != null) { if (mPlayingRecordedProgram) { return mRecordedPlaybackStartTime; } else { return mCurrentProgram.getStartTimeUtcMillis(); } } return TvInputManager.TIME_SHIFT_INVALID_TIME; }
Example 18
Source File: BaseTvInputService.java From androidtv-sample-inputs with Apache License 2.0 | 4 votes |
@RequiresApi(api = Build.VERSION_CODES.M) @Override public long onTimeShiftGetCurrentPosition() { if (getTvPlayer() != null && mCurrentProgram != null) { if (mPlayingRecordedProgram) { long recordingStartTime = mCurrentProgram.getInternalProviderData().getRecordedProgramStartTime(); // If time shifting somehow shifted past (before) recording start time, // seek player back up to recording start time. if (getTvPlayer().getCurrentPosition() < recordingStartTime - mCurrentProgram.getStartTimeUtcMillis()) { getTvPlayer() .seekTo( recordingStartTime - mCurrentProgram.getStartTimeUtcMillis()); getTvPlayer().pause(); } return getTvPlayer().getCurrentPosition() - (recordingStartTime - mCurrentProgram.getStartTimeUtcMillis()) + mRecordedPlaybackStartTime; } else { mElapsedProgramTime = getTvPlayer().getCurrentPosition(); mTimeShiftedPlaybackPosition = mElapsedProgramTime + mElapsedAdsTime + mCurrentProgram.getStartTimeUtcMillis(); if (DEBUG) { Log.d(TAG, "Time Shift Current Position"); Log.d(TAG, "Elapsed program time: " + mElapsedProgramTime); Log.d(TAG, "Elapsed ads time: " + mElapsedAdsTime); Log.d( TAG, "Total elapsed time: " + (mTimeShiftedPlaybackPosition - mCurrentProgram.getStartTimeUtcMillis())); Log.d( TAG, "Time shift difference: " + (System.currentTimeMillis() - mTimeShiftedPlaybackPosition)); Log.d(TAG, "============================"); } return getCurrentTime(); } } return TvInputManager.TIME_SHIFT_INVALID_TIME; }
Example 19
Source File: BaseTvInputService.java From xipl with Apache License 2.0 | 4 votes |
@RequiresApi(api = Build.VERSION_CODES.M) @Override public long onTimeShiftGetCurrentPosition() { if (getTvPlayer() != null && mCurrentProgram != null) { if (mPlayingRecordedProgram) { long recordingStartTime = mCurrentProgram.getInternalProviderData().getRecordedProgramStartTime(); // If time shifting somehow shifted past (before) recording start time, // seek player back up to recording start time. if (getTvPlayer().getCurrentPosition() < recordingStartTime - mCurrentProgram.getStartTimeUtcMillis()) { getTvPlayer() .seekTo( recordingStartTime - mCurrentProgram.getStartTimeUtcMillis()); getTvPlayer().pause(); } return getTvPlayer().getCurrentPosition() - (recordingStartTime - mCurrentProgram.getStartTimeUtcMillis()) + mRecordedPlaybackStartTime; } else { mElapsedProgramTime = getTvPlayer().getCurrentPosition(); mTimeShiftedPlaybackPosition = mElapsedProgramTime + mElapsedAdsTime + mCurrentProgram.getStartTimeUtcMillis(); if (DEBUG) { Log.d(TAG, "Time Shift Current Position"); Log.d(TAG, "Elapsed program time: " + mElapsedProgramTime); Log.d(TAG, "Elapsed ads time: " + mElapsedAdsTime); Log.d( TAG, "Total elapsed time: " + (mTimeShiftedPlaybackPosition - mCurrentProgram.getStartTimeUtcMillis())); Log.d( TAG, "Time shift difference: " + (System.currentTimeMillis() - mTimeShiftedPlaybackPosition)); Log.d(TAG, "============================"); } return getCurrentTime(); } } return TvInputManager.TIME_SHIFT_INVALID_TIME; }