Ejemplo n.º 1
0
 protected void onCreate(Bundle bundle) {
   super.onCreate(bundle);
   setContentView(0x7f030070);
   bundle = (RelativeLayout) findViewById(0x7f0a00be);
   mTimer = new Timer();
   if (sSlot != null) {
     sSlot.setParameter("renderer.html.shouldUseDip", "true");
     android.widget.RelativeLayout.LayoutParams layoutparams =
         new android.widget.RelativeLayout.LayoutParams(-1, -1);
     layoutparams.addRule(13);
     ViewGroup viewgroup = sSlot.getBase();
     viewgroup.setLayoutParams(layoutparams);
     try {
       ((ViewGroup) viewgroup.getParent()).removeView(viewgroup);
     } catch (Exception exception) {
     }
     bundle.addView(viewgroup);
     sSlot.play();
     mTimer.schedule(new HomeTask(), 5000L);
     return;
   } else {
     mTimer.schedule(new HomeTask(), 0L);
     return;
   }
 }
 protected void onFreeWheelEvent(IEvent event) {
   Log.i(CLASSTAG, event.getType());
   if (event.getType().equals(adConstants.EVENT_REQUEST_COMPLETE())) {
     Log.d(CLASSTAG, "ad request complete");
     try {
       Thread.sleep(5000);
     } catch (InterruptedException e) {
     }
     this.prerollSlots =
         adContext.getSlotsByTimePositionClass(adConstants.TIME_POSITION_CLASS_PREROLL());
     this.postrollSlots =
         adContext.getSlotsByTimePositionClass(adConstants.TIME_POSITION_CLASS_POSTROLL());
     this.showDisplayAd();
     this.prepareMidRoll();
     this.playAdSlot(adConstants.TIME_POSITION_CLASS_PREROLL());
   } else if (event.getType().equals(adConstants.EVENT_SLOT_ENDED())) {
     String customId = (String) event.getData().get(adConstants.INFO_KEY_CUSTOM_ID());
     ISlot endedSlot = adContext.getSlotByCustomId(customId);
     if (endedSlot.getTimePositionClass() == adConstants.TIME_POSITION_CLASS_PREROLL()
         || endedSlot.getTimePositionClass() == adConstants.TIME_POSITION_CLASS_POSTROLL()) {
       this.playAdSlot(endedSlot.getTimePositionClass());
     }
   } else if (event.getType().equals(adConstants.EVENT_REQUEST_CONTENT_VIDEO_RESUME())) {
     this.resumeMainVideo();
   } else if (event.getType().equals(adConstants.EVENT_REQUEST_CONTENT_VIDEO_PAUSE())) {
     this.pauseMainVideo();
   }
 }
  private void prepareMidRoll() {
    final ArrayList<ISlot> mid_slots =
        adContext.getSlotsByTimePositionClass(adConstants.TIME_POSITION_CLASS_MIDROLL());

    Iterator<ISlot> iter = mid_slots.iterator();
    while (iter.hasNext()) {
      ISlot slot = iter.next();
      double tp = slot.getTimePosition();
      Log.i(CLASSTAG, "at " + tp + " has midroll");
      this.midrolls.put(tp, slot.getCustomId());
      this.midrollkeys.add(tp);
    }

    // get all overlay slots
    final ArrayList<ISlot> overlay_slots =
        adContext.getSlotsByTimePositionClass(adConstants.TIME_POSITION_CLASS_OVERLAY());

    // TODO: what if the overlay has the same time position with a mid-roll?
    iter = overlay_slots.iterator();
    while (iter.hasNext()) {
      ISlot slot = iter.next();
      double tp = slot.getTimePosition();
      Log.i(CLASSTAG, "at " + tp + " has overlay");
      this.midrolls.put(tp, slot.getCustomId());
      this.midrollkeys.add(tp);
    }

    Collections.sort(this.midrollkeys);
  }
 public void playAdSlot(int tpc) {
   if (tpc == adConstants.TIME_POSITION_CLASS_PREROLL()) {
     if (!this.prerollSlots.isEmpty()) {
       ISlot slot = this.prerollSlots.remove(0);
       Log.d(CLASSTAG, "playing slot: " + slot.toString());
       slot.play();
     } else {
       this.playMainVideo();
     }
   } else if (tpc == adConstants.TIME_POSITION_CLASS_POSTROLL()) {
     if (!this.postrollSlots.isEmpty()) {
       ISlot slot = this.postrollSlots.remove(0);
       Log.d(CLASSTAG, "playing slot: " + slot.toString());
       slot.play();
     } else {
       this.finish();
     }
   }
 }
Ejemplo n.º 5
0
 public static void setSlot(ISlot islot) {
   sSlot = islot;
   if (sSlot != null) {
     sSlot.setParameter("renderer.html.shouldUseDip", "true");
   }
 }