*/
private synchronized void setSubtitleAnchor() {
if ((mSubtitleController == null) && (ActivityThread.currentApplication() != null)) {
- getMediaTimeProvider();
+ final TimeProvider timeProvider = (TimeProvider) getMediaTimeProvider();
final HandlerThread thread = new HandlerThread("SetSubtitleAnchorThread");
thread.start();
Handler handler = new Handler(thread.getLooper());
@Override
public void run() {
Context context = ActivityThread.currentApplication();
- mSubtitleController = new SubtitleController(context, mTimeProvider, MediaPlayer.this);
+ mSubtitleController =
+ new SubtitleController(context, timeProvider, MediaPlayer.this);
mSubtitleController.setAnchor(new Anchor() {
@Override
public void setSubtitleWidget(RenderingWidget subtitleWidget) {
@Override
public Looper getSubtitleLooper() {
- return mTimeProvider.mEventHandler.getLooper();
+ return timeProvider.mEventHandler.getLooper();
}
});
thread.getLooper().quitSafely();
}
updateView(mActiveCues);
mNextScheduledTimeMs = -1;
- mTimeProvider.notifyAt(MediaTimeProvider.NO_TIME, this);
+ if (mTimeProvider != null) {
+ mTimeProvider.notifyAt(MediaTimeProvider.NO_TIME, this);
+ }
}
/** @hide */