private void loadVideo() {
    getWindow().setFormat(PixelFormat.TRANSLUCENT);
    mVideoView = (VideoView) findViewById(R.id.imageViewCenter);
    mVideoView.setMediaController(new MediaController(this));
    Uri video = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.water_drop);
    mVideoView.setVideoURI(video);
    mVideoView.start();

    if (isLEFT) {

      lp.setMargins(1200, 0, -1000, 0);
      mThumbnailTopLayout.setVisibility(View.GONE);
      mThumnailBottomLayout.setVisibility(View.GONE);

    } else {
      lp.setMargins(-640, 0, 640, 0);
    }
    mVideoView.setLayoutParams(lp);

    mVideoView.setClickable(true);
    mVideoView.setOnTouchListener(
        new OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            // System.out.println(mVideoView);
            // mVideoView.stopPlayback();
            lp.setMargins(0, 0, 0, 0);
            mVideoView.setLayoutParams(lp);
            return true;
          }
        });
  }
  private void createView() {
    // Linear Layout
    LinearLayout linearLayout = new LinearLayout(this);
    linearLayout.setId(1);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setGravity(Gravity.CENTER);
    linearLayout.setBackgroundColor(Color.BLACK);
    this.setContentView(linearLayout);

    // Relative Layout
    RelativeLayout relativeLayout = new RelativeLayout(this);
    relativeLayout.setId(2);
    relativeLayout.setGravity(Gravity.CENTER);
    relativeLayout.setBackgroundColor(Color.BLACK);
    RelativeLayout.LayoutParams relativeLayoutParams =
        new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
    relativeLayout.setLayoutParams(relativeLayoutParams);
    linearLayout.addView(relativeLayout);

    // Video View
    videoView = new VideoView(this);
    videoView.setId(3);
    RelativeLayout.LayoutParams videoViewParams =
        new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    videoViewParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    videoView.setLayoutParams(videoViewParams);
    relativeLayout.addView(videoView);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_canciones);

    tituloView = (TextView) findViewById(R.id.texto_canciones);

    server = new BusinessCanciones(php);

    // Creo videoview solo 1 vez
    video = new VideoView(this);
    ViewGroup.LayoutParams params =
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    video.setLayoutParams(params);
    controller =
        new MediaController(this) {
          /*@Override
          public void hide()
          {}*/

          @Override
          public boolean dispatchKeyEvent(KeyEvent event) {
            if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
              finish();
            }
            return super.dispatchKeyEvent(event);
          }
        };
    controller.setAnchorView(video);
    video.setMediaController(controller);

    // Cargo la primera cancion
    siguienteCancion();
  }
  public void showVideo(String advice) {
    VideoView video = new VideoView(this);
    video.setVideoURI(Uri.parse(advice));
    ViewGroup.LayoutParams params =
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    video.setLayoutParams(params);

    MediaController controller =
        new MediaController(this) {
          @Override
          public void hide() {}

          @Override
          public boolean dispatchKeyEvent(KeyEvent event) {
            if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) finish();
            return super.dispatchKeyEvent(event);
          }
        };
    controller.setAnchorView(video);
    video.setMediaController(controller);

    layout.addView(video);
    video.start();
  }
  /** Create the view in which the video will be rendered. */
  private void setupView() {
    LinearLayout lLinLayout = new LinearLayout(this);
    lLinLayout.setId(1);
    lLinLayout.setOrientation(LinearLayout.VERTICAL);
    lLinLayout.setGravity(Gravity.CENTER);
    lLinLayout.setBackgroundColor(Color.BLACK);

    LayoutParams lLinLayoutParms =
        new LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
    lLinLayout.setLayoutParams(lLinLayoutParms);

    this.setContentView(lLinLayout);

    RelativeLayout lRelLayout = new RelativeLayout(this);
    lRelLayout.setId(2);
    lRelLayout.setGravity(Gravity.CENTER);
    lRelLayout.setBackgroundColor(Color.BLACK);
    android.widget.RelativeLayout.LayoutParams lRelLayoutParms =
        new android.widget.RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
    lRelLayout.setLayoutParams(lRelLayoutParms);
    lLinLayout.addView(lRelLayout);

    mVideoView = new VideoView(this);
    mVideoView.setId(3);
    android.widget.RelativeLayout.LayoutParams lVidViewLayoutParams =
        new android.widget.RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lVidViewLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    mVideoView.setLayoutParams(lVidViewLayoutParams);
    lRelLayout.addView(mVideoView);

    mProgressBar = new ProgressBar(this);
    mProgressBar.setIndeterminate(true);
    mProgressBar.setVisibility(View.VISIBLE);
    mProgressBar.setEnabled(true);
    mProgressBar.setId(4);
    android.widget.RelativeLayout.LayoutParams lProgressBarLayoutParms =
        new android.widget.RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lProgressBarLayoutParms.addRule(RelativeLayout.CENTER_IN_PARENT);
    mProgressBar.setLayoutParams(lProgressBarLayoutParms);
    lRelLayout.addView(mProgressBar);

    mProgressMessage = new TextView(this);
    mProgressMessage.setId(5);
    android.widget.RelativeLayout.LayoutParams lProgressMsgLayoutParms =
        new android.widget.RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lProgressMsgLayoutParms.addRule(RelativeLayout.CENTER_HORIZONTAL);
    lProgressMsgLayoutParms.addRule(RelativeLayout.BELOW, 4);
    mProgressMessage.setLayoutParams(lProgressMsgLayoutParms);
    mProgressMessage.setTextColor(Color.LTGRAY);
    mProgressMessage.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
    mProgressMessage.setText("...");
    lRelLayout.addView(mProgressMessage);
  }
Exemple #6
0
  private void setVideoViewPosition() {
    if (getResources().getConfiguration().orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
      mPortraitContent.setVisibility(View.VISIBLE);
      int[] locationArray = new int[2];
      // videoView的位置
      mPortraitPosition.getLocationOnScreen(locationArray);
      RelativeLayout.LayoutParams params =
          new RelativeLayout.LayoutParams(
              mPortraitPosition.getWidth(), mPortraitPosition.getHeight());
      params.leftMargin = locationArray[0];
      params.topMargin = locationArray[1];

      mVideoView.setLayoutParams(params);
    } else {
      mPortraitContent.setVisibility(View.GONE);

      RelativeLayout.LayoutParams params =
          new RelativeLayout.LayoutParams(
              RelativeLayout.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
      params.addRule(RelativeLayout.CENTER_IN_PARENT);
      mVideoView.setLayoutParams(params);
    }
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getWindow().setWindowAnimations(0); // Do not animate the view when it gets pushed on the screen
    setContentView(R.layout.videoview);

    CustomApp appState = ((CustomApp) getApplicationContext());
    unzippedDir = appState.getUnzippedDir();
    // videoView =  (VideoView) findViewById(R.id.surface_view); //new VideoView(VideoViewer.this);

    // Get the extras (video filename) out of the new intent
    Intent intent = getIntent();
    if (intent != null) videoFile = intent.getStringExtra("video");
    if (intent != null) packagePath = intent.getStringExtra("path");

    File clip = new File(/*unzippedDir + */ packagePath + File.separator + videoFile);
    System.out.println("Complete video path === " + packagePath + File.separator + videoFile);

    try {
      if (clip.exists()) {

        videoView = new VideoView(VideoViewer.this);
        videoView.setVideoPath(clip.getAbsolutePath());

        videoView.setLayoutParams(
            new Gallery.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

        ctlr = new MediaController(VideoViewer.this);
        ctlr.setMediaPlayer(videoView);
        videoView.setMediaController(ctlr);
        videoView.requestFocus();
        videoView.start();
        setContentView(videoView);

      } else {
        TextView tv = new TextView(this);
        tv.setText("File does not exist");
        setContentView(tv);
      }
    } catch (OutOfMemoryError E) {
      // Release some (all) of the above objects
      System.out.println("Out of Memory Exception");
      TextView txtView = new TextView(VideoViewer.this);
      txtView.setText("Error: Out of Memory - video file is too big to load!");
      setContentView(txtView);
    }
  }
Exemple #8
0
 public e(Context context) {
   super(context);
   context = new MediaController(getContext());
   a = new VideoView(getContext());
   context.setAnchorView(this);
   a.setMediaController(context);
   context = new android.widget.RelativeLayout.LayoutParams(-1, -1);
   context.addRule(11, -1);
   context.addRule(9, -1);
   context.addRule(10, -1);
   context.addRule(12, -1);
   context.addRule(13);
   a.setLayoutParams(context);
   addView(a);
   g = new Handler();
   context = new b(this);
   g.postDelayed(context, 250L);
   f = new Handler();
   context = new a(this);
   f.postDelayed(context, 250L);
 }
 public void setVideoRegion(int left, int top, int width, int height) {
   if (mVideoView != null && !mConformanceMode) {
     mVideoView.setLayoutParams(new LayoutParams(width, height, left, top));
   }
 }
  @SuppressWarnings("deprecation")
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.rerun_b);

    // -----------------Get intent Data-----------------
    rerunPath = getIntent().getStringExtra("path");
    rerunTitle = getIntent().getStringExtra("title");
    radioTag = getIntent().getIntExtra("tag", 0);
    rerunDesc = getIntent().getStringExtra("desc");

    BackBT = (ImageView) findViewById(R.id.RadioType);
    headLayout = (RelativeLayout) findViewById(R.id.headLayout);
    typeButton = (ImageView) findViewById(R.id.typeButton);
    checkinBT = (ImageView) findViewById(R.id.checkinButton);
    leftLine = (LinearLayout) findViewById(R.id.leftLine);
    imgWave = (ImageView) findViewById(R.id.imgWave);
    Linear_Title = (LinearLayout) findViewById(R.id.Linear_txtVideo);
    scDesc = (ScrollView) findViewById(R.id.scDesc);
    PG = (ProgressBar) findViewById(R.id.pg);

    txtTitle = (TextView) findViewById(R.id.txtTitle);
    txtTime = (TextView) findViewById(R.id.txtTime);
    txtDesc = (TextView) findViewById(R.id.txtDesc);
    //      !!! headTitle = (TextView)findViewById(R.id.headTitle);
    //      !!! txtTime.setText();

    setRadioTheme(radioTag);
    txtTitle.setText(rerunTitle);
    txtDesc.setText(rerunDesc);

    // -----------------Get Display Size----------------
    Display display = getWindowManager().getDefaultDisplay();
    width = display.getWidth(); // deprecated
    height = display.getHeight(); // deprecated

    conMgr =
        (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); // connection state
    if (isNetworkAvailable() == false) {
      displayAlert("กรุณาเขื่อมต่ออินเทอร์เน็ตก่อนการใช้งาน AtimeOnline", true);
    }

    mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    notification =
        new Notification(
            R.raw.splash_screen_logo, "AtimeRerun is Running", System.currentTimeMillis());
    Intent notificationIntent = new Intent(getApplicationContext(), AtimeRerunActivity.class);
    notification.flags = Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR;
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

    notification.setLatestEventInfo(
        getBaseContext(), "AtimeMedia Radio", rerunTitle, contentIntent);

    vRadioView = (VideoView) findViewById(R.id.radioView);
    MediaController mVideoController = new MediaController(this);
    mVideoController.setAnchorView(vRadioView);
    vRadioView.setMediaController(mVideoController);

    int screenWidth = width;
    int screenHeight = (width * 3) / 4;

    android.view.ViewGroup.LayoutParams lp = vRadioView.getLayoutParams();
    lp.width = screenWidth;
    lp.height = screenHeight;
    vRadioView.setLayoutParams(lp);

    setLayoutFunction();

    pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    wakeLock = pm.newWakeLock(pm.FULL_WAKE_LOCK, "wakelock");

    setRadioPath();
    wakeLock.acquire();

    BackBT.setOnTouchListener(
        new OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            finish();
            // checkNote = true;
            return false;
          }
        });

    checkinBT.setOnTouchListener(
        new OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            int action = event.getAction();
            switch (action) {
              case MotionEvent.ACTION_DOWN:
                {
                  checkinBT.setImageResource(R.raw.check_in_menu_btn_active);
                  Intent iCheckin = new Intent(getApplicationContext(), AtimeCheckinActivity.class);
                  checkResume = 1;
                  checkNote = true;
                  Log.d("checkresume", String.valueOf(checkResume));
                  switch (radioTag) {
                    case 0:
                      iCheckin.putExtra(
                          "checkinPath",
                          "http://social.atimemedia.com/checkin_android/rerun/chill89");
                      break;
                    case 1:
                      iCheckin.putExtra(
                          "checkinPath",
                          "http://social.atimemedia.com/checkin_android/rerun/hot915");
                      break;
                    case 2:
                      iCheckin.putExtra(
                          "checkinPath",
                          "http://social.atimemedia.com/checkin_android/rerun/efm94");
                      break;
                    case 3:
                      iCheckin.putExtra(
                          "checkinPath",
                          "http://social.atimemedia.com/checkin_android/rerun/greenwave");
                      break;
                  }
                  startActivity(iCheckin);
                }
                break;
              case MotionEvent.ACTION_UP:
                checkinBT.setImageResource(R.raw.check_in_menu_btn);
                break;
              default:
            }
            return true;
          }
        });

    vRadioView.setOnPreparedListener(
        new OnPreparedListener() {

          @Override
          public void onPrepared(MediaPlayer mp) {
            // TODO Auto-generated method stub
            PG.setVisibility(View.GONE);
          }
        });
  }