gt:         if (mWasDestroyed) {
context: package com.kaltura.playersdk.players;
  
  import android.content.Context;
  import android.drm.DrmErrorEvent;
  import android.drm.DrmEvent;
  import android.media.MediaPlayer;
  import android.net.Uri;
  import android.os.Build;
  import android.os.Handler;
  import android.os.Looper;
  import android.support.annotation.NonNull;
  import android.support.annotation.Nullable;
  import android.view.Gravity;
  import android.view.SurfaceHolder;
  import android.widget.FrameLayout;
  import android.widget.VideoView;
  
  import com.kaltura.playersdk.tracks.TrackFormat;
  import com.kaltura.playersdk.tracks.TrackType;
  import com.kaltura.playersdk.PlayerViewController;
  import com.kaltura.playersdk.drm.WidevineDrmClient;
  
  
  
  import java.util.Collections;
  import java.util.Set;
  
  import static com.kaltura.playersdk.utils.LogUtils.LOGD;
  import static com.kaltura.playersdk.utils.LogUtils.LOGE;
  import static com.kaltura.playersdk.utils.LogUtils.LOGI;
  import static com.kaltura.playersdk.utils.LogUtils.LOGW;
  
  
  /**
   * Created by noamt on 10/27/15.
   */
  public class KWVCPlayer
          extends FrameLayout
          implements KPlayer {
  
      private static final String TAG = "KWVCPlayer";
  
      private static final long PLAYHEAD_UPDATE_INTERVAL = 200;
      @Nullable private VideoView mPlayer;
      private String mAssetUri;
      private String mLicenseUri;
      private WidevineDrmClient mDrmClient;
      @NonNull private KPlayerListener mListener;
      @NonNull private KPlayerCallback mCallback;
      private boolean mShouldCancelPlay;
      private boolean mShouldPlayWhenReady;
      @Nullable private PlayheadTracker mPlayheadTracker;
      private PrepareState mPrepareState;
      @NonNull private PlayerState mSavedState;
      private boolean isFirstPreparation = true;
      private int mCurrentPosition;
      private boolean mWasDestroyed;
      private String mLastSentEvent = "";
  
      public static Set<KMediaFormat> supportedFormats(Context context) {
          if (WidevineDrmClient.isSupported(context)) {
              return Collections.singleton(KMediaFormat.wvm_widevine);
          }
          return Collections.emptySet();
      }
  
      /**
       * Construct a new Widevine Classic player.
       * @param context
       * @throws UnsupportedOperationException if Widevine Classic is not supported by platform.
       */
      public KWVCPlayer(Context context) {
          super(context);
          mDrmClient = new WidevineDrmClient(context);
          mDrmClient.setEventListener(new WidevineDrmClient.EventListener() {
              @Override
              public void onError(final DrmErrorEvent event) {
                  mShouldCancelPlay = true;
                  KWVCPlayer.this.post(new Runnable() {
                      @Override
                      public void run() {
                          mListener.eventWithValue(KWVCPlayer.this, KPlayerListener.ErrorKey, "DRM error");
                      }
                  });
              }
  
              @Override
              public void onEvent(DrmEvent event) {
  
              }
          });
  
          mSavedState = new PlayerState();
  
          // Set no-op listeners so we don't have to check for null on use
          setPlayerListener(null);
          setPlayerCallback(null);
      }
  
      // Convert file:///local/path/a.wvm to /local/path/a.wvm
      // Convert http://example.com/path/a.wvm to widevine://example.com/path/a.wvm
      // Every else remains the same.
      public static String getWidevineAssetPlaybackUri(String assetUri) {
          if (assetUri.startsWith("file:")) {
              assetUri = Uri.parse(assetUri).getPath();
          } else if (assetUri.startsWith("http:")) {
              assetUri = assetUri.replaceFirst("^http:", "widevine:");
          }
          return assetUri;
      }
  
      // Convert file:///local/path/a.wvm to /local/path/a.wvm
      // Convert widevine://example.com/path/a.wvm to http://example.com/path/a.wvm
      // Everything else remains the same.
      public static String getWidevineAssetAcquireUri(String assetUri) {
          if (assetUri.startsWith("file:")) {
              assetUri = Uri.parse(assetUri).getPath();
          } else if (assetUri.startsWith("widevine:")) {
              assetUri = assetUri.replaceFirst("widevine", "http");
          }
          return assetUri;
      }
  
  
      @Override
      public void setPlayerListener(KPlayerListener listener) {
          if (listener == null) {
              // Create a no-op listener
              listener = new KPlayerListener() {
                  public void eventWithValue(KPlayer player, String eventName, String eventValue) {}
                  public void eventWithJSON(KPlayer player, String eventName, String jsonValue) {}
                  public void asyncEvaluate(String expression, String expressionID, PlayerViewController.EvaluateListener evaluateListener) {}
                  public void contentCompleted(KPlayer currentPlayer) {}
              };
          }
          mListener = listener;
      }
  
      @Override
      public void setPlayerCallback(KPlayerCallback callback) {
          if (callback == null) {
              // Create a no-op callback
              callback = new KPlayerCallback() {
                  public void playerStateChanged(int state) {}
              };
          }
          mCallback = callback;
      }
  
      @Override
      public void setPlayerSource(String source) {
  
          mAssetUri = source;
  
          if (mLicenseUri != null) {
              isFirstPreparation = true;
              preparePlayer();
          } else {
              LOGD(TAG, "setPlayerSource: waiting for licenseUri.");
          }
      }
  
      @Override
      public void setLicenseUri(String licenseUri) {
          mLicenseUri = licenseUri;
          if (mAssetUri != null) {
              preparePlayer();
          } else {
              LOGD(TAG, "setLicenseUri: Waiting for assetUri.");
          }
      }
  
      @Override
      public long getCurrentPlaybackTime() {
          int currentPos = (mPlayer != null) ? mPlayer.getCurrentPosition() : 0;
          LOGD(TAG, "getCurrentPlaybackTime: current position = " + currentPos);
          return currentPos;
      }
  
      @Override
      public void setCurrentPlaybackTime(long currentPlaybackTime) {
          if (mPlayer != null) {
              LOGD(TAG, "setCurrentPlaybackTime: seekTo currentPlaybackTime " + currentPlaybackTime);
              mPlayer.seekTo((int) (currentPlaybackTime));
          }
      }
  
      @Override
      public long getDuration() {
          return mPlayer != null ? mPlayer.getDuration() : 0;
      }
  
      @Override
      public void play() {
  
          // If already playing, don't do anything.
          if (mWasDestroyed || mPlayer == null || mPlayer.isPlaying()) {
              return;
          }
  
          // If play should be canceled, don't even start.
          if (mShouldCancelPlay) {
              mShouldCancelPlay = false;
              return;
          }
  
          // If not prepared, ask player to start when prepared.
          if (mPrepareState != PrepareState.Prepared) {
              mShouldPlayWhenReady = true;
              preparePlayer();
              return;
          }
  
          if (mSavedState.position != 0) {
              mShouldPlayWhenReady = true;
              setCurrentPlaybackTime(mSavedState.position); // will start playing after seek complete
              return;
              //mSavedState.position = 0;
          }
          mPlayer.requestFocus();
          mPlayer.start();
  
          if (mPlayheadTracker == null) {
              mPlayheadTracker = new PlayheadTracker();
          }
          mPlayheadTracker.start();
          changePlayPauseState("play");
      }
  
      @Override
      public void pause() {
  