Exemple #1
0
  private void setAdvPathAndRequestNext() {
    String localfile = Const.DOWNLOAD_PATH + Util.VideoFileDir + Const.DOWNLOADING_SMALLVIDEO;
    File tempFile = new File(localfile);
    if (!tempFile.exists()) {
      RichMediaAd tempad =
          (RichMediaAd)
              serializeManager.readSerializableData(Const.DOWNLOAD_PATH + Util.VideoFileDir + "ad");
      if (tempad != null) {
        mAd = tempad;
        if (tempad.getVideo() != null) {
          this.mVideoData.videoUrl = mAd.getVideo().videoUrl;
        } else {
          initInterstitialView();
        }
      }
    }
    String path = this.mVideoData.videoUrl;
    Log.d("Jas", "path1=" + path);
    if (Util.CACHE_MODE) {
      if (Util.PlayingSmallVideoName == null) {
        path =
            getPlayPath(
                Const.DOWNLOAD_PATH
                    + Util.VideoFileDir
                    + Const.DOWNLOAD_SMALLVIDEO
                    + Util.ExternalName,
                path);
        Log.d("Jas", "path2=" + path);
      } else {
        if (Util.PlayingSmallVideoName.contains("_ts")) { // is playing done
          path =
              getPlayPath(
                  Const.DOWNLOAD_PATH
                      + Util.VideoFileDir
                      + Const.DOWNLOAD_SMALLVIDEO
                      + Util.ExternalName,
                  path);
          Log.d("Jas", "path3=" + path);
        } else if (Util.PlayingSmallVideoName.contains("http")) { // is playing online	
          path =
              getPlayPath(
                  Const.DOWNLOAD_PATH
                      + Util.VideoFileDir
                      + Const.DOWNLOAD_SMALLVIDEO
                      + Util.ExternalName,
                  path);
          Log.d("Jas", "path4=" + path);
        } else { // is playing ts
          path =
              getPlayPath(
                  Const.DOWNLOAD_PATH
                      + Util.VideoFileDir
                      + Const.DOWNLOAD_SMALLVIDEO
                      + "_ts"
                      + Util.ExternalName,
                  path);
          Log.d("Jas", "path5=" + path);
        }
      }
    }
    Log.d("Jas", "path6=" + path);
    new ImpressionThread(
            mContext, mAd.getmImpressionUrl(), Util.PublisherId, Util.AD_TYPE.FULL_SCREEN_VIDEO)
        .start();
    // change by Jas
    if (mAd.getmTrackingUrl().size() > 0) {
      AdMonitorManager.getInstance(mContext).AddTRACKINGURL(mAd.getmTrackingUrl());
    }
    // end change by Jas
    Util.PlayingSmallVideoName = path;
    this.mVideoView.setVideoPath(path);
    String pathTemp = Const.DOWNLOAD_PATH + Util.VideoFileDir + "ad";
    File cacheDir = new File(Const.DOWNLOAD_PATH + Util.VideoFileDir);
    if (!cacheDir.exists()) cacheDir.mkdirs();

    new DownloadSmallVideoThread(pathTemp, mContext, request).start();
  }
Exemple #2
0
  private void initInterstitialView() {
    new Handler().postDelayed(RequestNextAdv, 5000);
    this.mInterstitialData = this.mAd.getInterstitial();
    this.mInterstitialAutocloseReset = false;
    this.mInterstitialView = new WebFrame((Activity) mContext, true, false, false);
    this.mInterstitialView.setBackgroundColor(Color.BLACK); //
    this.mInterstitialView.setOnPageLoadedListener(this.mOnInterstitialLoadedListener);
    if (this.mInterstitialController != null) {
      layout.removeView(this.mInterstitialController);
    }
    this.mInterstitialController = new InterstitialController(mContext, this.mInterstitialData);
    this.mInterstitialController.setBrowser(this.mInterstitialView);
    this.mInterstitialController.setBrowserView(this.mInterstitialView);
    this.mInterstitialController.setOnResetAutocloseListener(this.mOnResetAutocloseListener);
    layout.addView(
        this.mInterstitialController,
        new FrameLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, Gravity.CENTER));
    if (this.mInterstitialData.showNavigationBars) this.mInterstitialController.show(0);
    if (this.mInterstitialData.showSkipButton) {

      this.mSkipButton = new ImageView(mContext);
      this.mSkipButton.setAdjustViewBounds(false);
      FrameLayout.LayoutParams params = null;

      int buttonSize =
          (int)
              TypedValue.applyDimension(
                  TypedValue.COMPLEX_UNIT_DIP,
                  this.skipButtonSizeLand,
                  this.getResources().getDisplayMetrics());

      int size =
          Math.min(
              this.getResources().getDisplayMetrics().widthPixels,
              this.getResources().getDisplayMetrics().heightPixels);
      buttonSize = (int) (size * 0.1);

      params = new FrameLayout.LayoutParams(buttonSize, buttonSize, Gravity.TOP | Gravity.RIGHT);

      if (this.mInterstitialData.orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
        final int margin =
            (int)
                TypedValue.applyDimension(
                    TypedValue.COMPLEX_UNIT_DIP, 8, this.getResources().getDisplayMetrics());
        params.topMargin = margin;
        params.rightMargin = margin;
      } else {
        final int margin =
            (int)
                TypedValue.applyDimension(
                    TypedValue.COMPLEX_UNIT_DIP, 10, this.getResources().getDisplayMetrics());
        params.topMargin = margin;
        params.rightMargin = margin;
      }

      if (this.mInterstitialData.skipButtonImage != null
          && this.mInterstitialData.skipButtonImage.length() > 0) {
        this.mSkipButton.setBackgroundDrawable(null);
        this.mResourceManager.fetchResource(
            mContext,
            this.mInterstitialData.skipButtonImage,
            ResourceManager.DEFAULT_SKIP_IMAGE_RESOURCE_ID);
      }
      //			else
      //				this.mSkipButton.setImageDrawable(mResourceManager.getResource(
      //						mContext, ResourceManager.DEFAULT_SKIP_IMAGE_RESOURCE_ID));
      //			this.mSkipButton
      //					.setOnClickListener(this.mOnInterstitialSkipListener);
      if (this.mInterstitialData.showSkipButtonAfter > 0) {
        this.mCanClose = false;
        this.mSkipButton.setVisibility(View.GONE);
        if (this.mInterstitialLoadingTimer == null) {
          //					final InterstitialLoadingTimeoutTask loadingTimeoutTask = new
          // InterstitialLoadingTimeoutTask();
          //					this.mInterstitialLoadingTimer = new Timer();
          //					this.mInterstitialLoadingTimer.schedule(loadingTimeoutTask,
          //							Const.CONNECTION_TIMEOUT);
        }

      } else {
        this.mCanClose = true;
        this.mSkipButton.setVisibility(View.VISIBLE);
      }
      layout.addView(this.mSkipButton, params);
    } else this.mCanClose = false;
    this.mInterstitialView.setOnClickListener(this.mInterstitialClickListener);
    setAdvImgPathAndRequestNext();

    switch (this.mInterstitialData.interstitialType) {
      case InterstitialData.INTERSTITIAL_MARKUP:
        if (Util.isCacheLoaded()) {
          String textData = this.mInterstitialData.interstitialMarkup;
          if (textData != null) {
            int startInd = textData.indexOf("<img") + 10;
            int endInd = textData.indexOf(">", startInd) - 1;
            String thisImageText = textData.substring(startInd, endInd);
            URL url = null;
            try {
              url = new URL(thisImageText);
            } catch (MalformedURLException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
            if (url != null) {
              Util.ExternalName = "." + Util.getExtensionName(url.getPath());
            } else {
              Util.ExternalName = ".jpg";
            }
          }
          new ImpressionThread(
                  mContext,
                  mAd.getmImpressionUrl(),
                  Util.PublisherId,
                  Util.AD_TYPE.FULL_SCREEN_VIDEO)
              .start();

          // change by Jas
          if (mAd.getmTrackingUrl().size() > 0) {
            AdMonitorManager.getInstance(mContext).AddTRACKINGURL(mAd.getmTrackingUrl());
          }
          // end change by Jas

          this.mInterstitialView.setMarkup(this.mInterstitialData.interstitialMarkup);
        }
        break;
      case InterstitialData.INTERSTITIAL_URL:
        this.mInterstitialView.loadUrl(this.mInterstitialData.interstitialUrl);
        break;
    }
  }