Program: 62833
Project: 62833
Buggy source:
/** 
 * External extras: - position (long) - position of the video to start with (in ms) - subtitles_location (String) - location of a subtitles file to load - from_start (boolean) - Whether playback should start from start or from resume point - title (String) - video title, will be guessed from file if not set.
 */
@TargetApi(12) @SuppressWarnings({"String_Node_Str"}) private void loadMedia(){
  if (mService == null)   return;
  mUri=null;
  mIsPlaying=false;
  String title=getResources().getString(R.string.title);
  boolean fromStart=false;
  String itemTitle=null;
  int positionInPlaylist=-1;
  Intent intent=getIntent();
  Bundle extras=intent.getExtras();
  long savedTime=extras != null ? extras.getLong(PLAY_EXTRA_START_TIME) : 0L;
  if (extras != null && savedTime == 0L)   savedTime=extras.getInt(PLAY_EXTRA_START_TIME);
  final KeyguardManager km=(KeyguardManager)VLCApplication.getAppContext().getSystemService(KEYGUARD_SERVICE);
  if (km.inKeyguardRestrictedInputMode())   mWasPaused=true;
  if (mWasPaused)   Log.d(TAG,"String_Node_Str");
  if (intent.getData() != null)   mUri=intent.getData();
  if (extras != null) {
    if (intent.hasExtra(PLAY_EXTRA_ITEM_LOCATION))     mUri=extras.getParcelable(PLAY_EXTRA_ITEM_LOCATION);
    fromStart=extras.getBoolean(PLAY_EXTRA_FROM_START,true);
    mAskResume&=!fromStart;
    positionInPlaylist=extras.getInt(PLAY_EXTRA_OPENED_POSITION,-1);
  }
  if (intent.hasExtra(PLAY_EXTRA_SUBTITLES_LOCATION))   mSubtitleSelectedFiles.add(extras.getString(PLAY_EXTRA_SUBTITLES_LOCATION));
  if (intent.hasExtra(PLAY_EXTRA_ITEM_TITLE))   itemTitle=extras.getString(PLAY_EXTRA_ITEM_TITLE);
  if (positionInPlaylist != -1 && mService.hasMedia()) {
    Log.d(TAG,"String_Node_Str" + positionInPlaylist);
    MediaWrapper openedMedia=mService.getMedias().get(positionInPlaylist);
    if (openedMedia == null) {
      encounteredError();
      return;
    }
    mUri=openedMedia.getUri();
    itemTitle=openedMedia.getTitle();
    updateSeekable(mService.isSeekable());
    updatePausable(mService.isPausable());
  }
  if (mUri != null) {
    if (mService.hasMedia() && !mUri.equals(mService.getCurrentMediaWrapper().getUri()))     mService.stop();
    MediaWrapper media=MediaDatabase.getInstance().getMedia(mUri);
    if (media == null && TextUtils.equals(mUri.getScheme(),"String_Node_Str") && mUri.getPath() != null && mUri.getPath().startsWith("String_Node_Str")) {
      mUri=FileUtils.convertLocalUri(mUri);
      media=MediaDatabase.getInstance().getMedia(mUri);
    }
    if (media != null) {
      if (media.getTime() > 0 && !fromStart && positionInPlaylist == -1) {
        if (mAskResume) {
          showConfirmResumeDialog();
          return;
        }
      }
      intent.putExtra(PLAY_EXTRA_FROM_START,false);
      if (fromStart || mService.isPlaying())       media.setTime(0L);
 else       if (savedTime <= 0L)       savedTime=media.getTime();
      mLastAudioTrack=media.getAudioTrack();
      mLastSpuTrack=media.getSpuTrack();
    }
 else {
      if (savedTime > 0L && mAskResume) {
        showConfirmResumeDialog();
        return;
      }
 else {
        long rTime=mSettings.getLong(PreferencesActivity.VIDEO_RESUME_TIME,-1);
        if (rTime > 0 && !fromStart) {
          if (mAskResume) {
            showConfirmResumeDialog();
            return;
          }
 else {
            Editor editor=mSettings.edit();
            editor.putLong(PreferencesActivity.VIDEO_RESUME_TIME,-1);
            editor.apply();
            savedTime=rTime;
          }
        }
      }
    }
    mService.addCallback(this);
    boolean hasMedia=mService.hasMedia();
    if (hasMedia)     media=mService.getCurrentMediaWrapper();
 else     if (media == null)     media=new MediaWrapper(mUri);
    if (mWasPaused)     media.addFlags(MediaWrapper.MEDIA_PAUSED);
    if (intent.hasExtra(PLAY_DISABLE_HARDWARE))     media.addFlags(MediaWrapper.MEDIA_NO_HWACCEL);
    media.removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
    media.addFlags(MediaWrapper.MEDIA_VIDEO);
    if (savedTime <= 0L && media != null && media.getTime() > 0L)     savedTime=media.getTime();
    if (savedTime > 0L && !mService.isPlaying())     mService.saveTimeToSeek(savedTime);
    if (!hasMedia)     mService.load(media);
 else     if (!mService.isPlaying())     mService.playIndex(positionInPlaylist);
 else {
      onPlaying();
    }
    getSubtitles();
    if (itemTitle == null)     title=mUri.getLastPathSegment();
  }
 else {
    mService.addCallback(this);
    mService.loadLastPlaylist(PlaybackService.TYPE_VIDEO);
    MediaWrapper mw=mService.getCurrentMediaWrapper();
    if (mw == null) {
      finish();
      return;
    }
    mUri=mService.getCurrentMediaWrapper().getUri();
  }
  if (itemTitle != null)   title=itemTitle;
  mTitle.setText(title);
  if (mWasPaused)   showOverlay(true);
}

Fixed version (ground truth):
/** 
 * External extras: - position (long) - position of the video to start with (in ms) - subtitles_location (String) - location of a subtitles file to load - from_start (boolean) - Whether playback should start from start or from resume point - title (String) - video title, will be guessed from file if not set.
 */
@TargetApi(12) @SuppressWarnings({"String_Node_Str"}) private void loadMedia(){
  if (mService == null)   return;
  mUri=null;
  mIsPlaying=false;
  String title=getResources().getString(R.string.title);
  boolean fromStart=false;
  String itemTitle=null;
  int positionInPlaylist=-1;
  Intent intent=getIntent();
  Bundle extras=intent.getExtras();
  long savedTime=extras != null ? extras.getLong(PLAY_EXTRA_START_TIME) : 0L;
  if (extras != null && savedTime == 0L)   savedTime=extras.getInt(PLAY_EXTRA_START_TIME);
  final KeyguardManager km=(KeyguardManager)VLCApplication.getAppContext().getSystemService(KEYGUARD_SERVICE);
  if (km.inKeyguardRestrictedInputMode())   mWasPaused=true;
  if (mWasPaused)   Log.d(TAG,"String_Node_Str");
  if (intent.getData() != null)   mUri=intent.getData();
  if (extras != null) {
    if (intent.hasExtra(PLAY_EXTRA_ITEM_LOCATION))     mUri=extras.getParcelable(PLAY_EXTRA_ITEM_LOCATION);
    fromStart=extras.getBoolean(PLAY_EXTRA_FROM_START,true);
    mAskResume&=!fromStart;
    positionInPlaylist=extras.getInt(PLAY_EXTRA_OPENED_POSITION,-1);
  }
  if (intent.hasExtra(PLAY_EXTRA_SUBTITLES_LOCATION))   mSubtitleSelectedFiles.add(extras.getString(PLAY_EXTRA_SUBTITLES_LOCATION));
  if (intent.hasExtra(PLAY_EXTRA_ITEM_TITLE))   itemTitle=extras.getString(PLAY_EXTRA_ITEM_TITLE);
  if (positionInPlaylist != -1 && mService.hasMedia()) {
    Log.d(TAG,"String_Node_Str" + positionInPlaylist);
    MediaWrapper openedMedia=mService.getMedias().get(positionInPlaylist);
    if (openedMedia == null) {
      encounteredError();
      return;
    }
    mUri=openedMedia.getUri();
    itemTitle=openedMedia.getTitle();
    updateSeekable(mService.isSeekable());
    updatePausable(mService.isPausable());
  }
  if (mUri != null) {
    if (mService.hasMedia() && !mUri.equals(mService.getCurrentMediaWrapper().getUri()))     mService.stop();
    MediaWrapper media=MediaDatabase.getInstance().getMedia(mUri);
    if (media == null && TextUtils.equals(mUri.getScheme(),"String_Node_Str") && mUri.getPath() != null && mUri.getPath().startsWith("String_Node_Str")) {
      mUri=FileUtils.convertLocalUri(mUri);
      media=MediaDatabase.getInstance().getMedia(mUri);
    }
    if (media != null) {
      if (media.getTime() > 0 && !fromStart && positionInPlaylist == -1) {
        if (mAskResume) {
          showConfirmResumeDialog();
          return;
        }
      }
      intent.putExtra(PLAY_EXTRA_FROM_START,false);
      if (fromStart || mService.isPlaying())       media.setTime(0L);
 else       if (savedTime <= 0L)       savedTime=media.getTime();
      mLastAudioTrack=media.getAudioTrack();
      mLastSpuTrack=media.getSpuTrack();
    }
 else {
      if (savedTime > 0L && mAskResume) {
        showConfirmResumeDialog();
        return;
      }
 else {
        long rTime=mSettings.getLong(PreferencesActivity.VIDEO_RESUME_TIME,-1);
        if (rTime > 0 && !fromStart) {
          if (mAskResume) {
            showConfirmResumeDialog();
            return;
          }
 else {
            Editor editor=mSettings.edit();
            editor.putLong(PreferencesActivity.VIDEO_RESUME_TIME,-1);
            editor.apply();
            savedTime=rTime;
          }
        }
      }
    }
    mService.addCallback(this);
    boolean hasMedia=mService.hasMedia();
    if (hasMedia)     media=mService.getCurrentMediaWrapper();
 else     if (media == null)     media=new MediaWrapper(mUri);
    if (mWasPaused)     media.addFlags(MediaWrapper.MEDIA_PAUSED);
    if (intent.hasExtra(PLAY_DISABLE_HARDWARE))     media.addFlags(MediaWrapper.MEDIA_NO_HWACCEL);
    media.removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
    media.addFlags(MediaWrapper.MEDIA_VIDEO);
    if (savedTime <= 0L && media != null && media.getTime() > 0L)     savedTime=media.getTime();
    if (savedTime > 0L && !mService.isPlaying())     mService.saveTimeToSeek(savedTime);
    if (!hasMedia)     mService.load(media);
 else     if (!mService.isPlaying())     mService.playIndex(positionInPlaylist);
 else {
      onPlaying();
    }
    getSubtitles();
    if (itemTitle == null)     title=mUri.getLastPathSegment();
  }
 else {
    mService.addCallback(this);
    mService.loadLastPlaylist(PlaybackService.TYPE_VIDEO);
    MediaWrapper mw=mService.getCurrentMediaWrapper();
    if (mw == null) {
      finish();
      return;
    }
    mUri=mService.getCurrentMediaWrapper().getUri();
  }
  if (itemTitle != null)   title=itemTitle;
  mTitle.setText(title);
  if (mWasPaused) {
    mForcedTime=savedTime;
    setOverlayProgress();
    mForcedTime=-1;
    showOverlay(true);
  }
}