Exemplo n.º 1
0
  @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();
  }
Exemplo n.º 2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    VideoView videoView = (VideoView) findViewById(R.id.videoView);
    videoView.setVideoPath("android.resource://" + getPackageName() + "/" + R.raw.demovideo);
    android.widget.MediaController mediaController = new android.widget.MediaController(this);
    mediaController.setAnchorView(videoView);
    videoView.setMediaController(mediaController);
    videoView.start();

    /*
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });
    */
  }
 private void h()
 {
   if (!B.p())
   {
     l.e(k, "changeToCastMode error, chromecast is not connected");
     return;
   }
   if (p != null) {
     p.hide();
   }
   m();
   A = 1;
   o.setVisibility(0);
   if (q == null)
   {
     q = new kk(this, this);
     if (r == null)
     {
       r = new kt(this);
       B.a(r);
       B.a(r);
       B.a(r);
     }
     q.setMediaPlayer(r);
     q.setAnchorView(o);
   }
   ((ImageView)z.findViewById(2131624054)).setImageResource(2130838531);
   if ((B.r() > 0) && (B.r() != 2)) {
     b.setVisibility(0);
   }
   J.sendMessageDelayed(J.obtainMessage(5), 1000L);
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fr_less_15_c, container, false);

    ImageButton button = (ImageButton) view.findViewById(R.id.playVideo);

    videoView = (VideoView) view.findViewById(R.id.less_15_c);
    MediaController mController = new MediaController(getActivity());
    mController.setAnchorView(videoView);
    Uri videoUri =
        Uri.parse("android.resource://com.example.dell.learnerintermediate/raw/less_15_c");
    videoView.setMediaController(mController);
    videoView.setVideoURI(videoUri);

    button.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {

            videoView.start();
          }
        });
    return view;
  }
Exemplo n.º 5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_vdo);
    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    final VideoView video1 = (VideoView) findViewById(R.id.videoView1);
    video1.setVideoPath(th);
    MediaController mediaController = new MediaController(this);
    mediaController.setAnchorView(video1);
    video1.setMediaController(mediaController);

    Toast.makeText(getBaseContext(), "รอสักครู่...", Toast.LENGTH_SHORT)
        .show(); // text preloading..

    video1.setOnPreparedListener(
        new MediaPlayer.OnPreparedListener() {

          @Override
          public void onPrepared(MediaPlayer mp) {
            Log.i(TAG, "Duration = " + video1.getDuration());
          }
        });

    video1.requestFocus(); // comment1

    video1.start();
    // finish(); //comment
  }
 @Override
 public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
   super.onViewCreated(view, savedInstanceState);
   mMediaController = new MediaController(view.getContext());
   mMediaController.setAnchorView(view);
   mSurfaceView.getHolder().addCallback(this);
 }
  @Override
  public void onPrepared(MediaPlayer mp) {
    mediaPlayer.start();
    mediacontroller.setMediaPlayer(this);
    mediacontroller.setAnchorView(findViewById(R.id.surfaceView));

    mediacontroller.show();
  }
Exemplo n.º 8
0
 private void attachMediaController() {
   if (mMediaPlayer != null && mMediaController != null) {
     mMediaController.setMediaPlayer(this);
     View anchorView = this.getParent() instanceof View ? (View) this.getParent() : this;
     mMediaController.setAnchorView(anchorView);
     mMediaController.setEnabled(mIsPrepared);
   }
 }
Exemplo n.º 9
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.player_activity);
    View root = findViewById(R.id.root);
    root.setOnTouchListener(
        new OnTouchListener() {
          @Override
          public boolean onTouch(View view, MotionEvent motionEvent) {
            if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
              toggleControlsVisibility();
            } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
              view.performClick();
            }
            return true;
          }
        });
    root.setOnKeyListener(
        new OnKeyListener() {
          @Override
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK
                || keyCode == KeyEvent.KEYCODE_ESCAPE
                || keyCode == KeyEvent.KEYCODE_MENU) {
              return false;
            }
            return mediaController.dispatchKeyEvent(event);
          }
        });

    shutterView = findViewById(R.id.shutter);
    debugRootView = findViewById(R.id.controls_root);

    videoFrame = (AspectRatioFrameLayout) findViewById(R.id.video_frame);
    surfaceView = (SurfaceView) findViewById(R.id.surface_view);
    surfaceView.getHolder().addCallback(this);
    debugTextView = (TextView) findViewById(R.id.debug_text_view);

    playerStateTextView = (TextView) findViewById(R.id.player_state_view);
    subtitleLayout = (SubtitleLayout) findViewById(R.id.subtitles);

    mediaController = new MediaController(this);
    mediaController.setAnchorView(root);
    retryButton = (Button) findViewById(R.id.retry_button);
    retryButton.setOnClickListener(this);
    videoButton = (Button) findViewById(R.id.video_controls);
    audioButton = (Button) findViewById(R.id.audio_controls);
    textButton = (Button) findViewById(R.id.text_controls);

    CookieHandler currentHandler = CookieHandler.getDefault();
    if (currentHandler != defaultCookieManager) {
      CookieHandler.setDefault(defaultCookieManager);
    }

    audioCapabilitiesReceiver = new AudioCapabilitiesReceiver(this, this);
    audioCapabilitiesReceiver.register();
  }
Exemplo n.º 10
0
 // ----------------start play video ----------------
 void playVideo() {
   videoView = (VideoView) findViewById(R.id.videoView);
   videoView.setVideoPath(
       "http://media.karaokecuatui.vn/mv/AnhVanYeuEmNhuNgayDauTien_CaoThaiSon.mp4");
   MediaController mediaController = new MediaController(this);
   mediaController.setAnchorView(videoView);
   videoView.setOnCompletionListener(completionlistener);
   videoView.setMediaController(mediaController);
   videoView.start();
 }
Exemplo n.º 11
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_menu__usuario__uno);
   final VideoView videoView = (VideoView) findViewById(R.id.webView);
   videoView.setVideoPath("http://www.ebookfrenzy.com/android_book/movie.mp4");
   videoView.start();
   MediaController mediaController = new MediaController(this);
   mediaController.setAnchorView(videoView);
   videoView.setMediaController(mediaController);
   videoView.start();
 }
Exemplo n.º 12
0
 @Override
 public void onPrepared(MediaPlayer mediaPlayer) {
   mediaController.setMediaPlayer(this);
   mediaController.setAnchorView(findViewById(R.id.main_audio_view));
   handler.post(
       new Runnable() {
         public void run() {
           mediaController.setEnabled(true);
           mediaController.show();
         }
       });
 }
Exemplo n.º 13
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.penampil_video);

    videoView = (VideoView) findViewById(R.id.VideoView);
    mediaController = new MediaController(this);
    mediaController.setAnchorView(videoView);
    Uri uri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.tahap1);
    videoView.setMediaController(mediaController);
    videoView.setVideoURI(uri);
    videoView.requestFocus();
    videoView.start();
  }
Exemplo n.º 14
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.video_alert_dialog);
    ok = (Button) findViewById(R.id.btn_ok_video);
    MediaController mediaController = new MediaController(getContext());
    Log.i("Video Uri", url.toString());
    vv = (VideoView) findViewById(R.id.vid_dialog);
    mediaController.setAnchorView(vv);
    vv.setVideoURI(url);

    vv.start();
    ok.setOnClickListener(this);
  }
Exemplo n.º 15
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    v = (VideoView) findViewById(R.id.videoView);
    MediaController ctrlr;
    String url = "http://techslides.com/demos/sample-videos/small.mp4";
    v.setVideoURI(Uri.parse("http://techslides.com/demos/sample-videos/small.mp4"));

    ctrlr = new MediaController(this);
    v.setOnCompletionListener(this);
    ctrlr.setAnchorView(v);
    ctrlr.setMediaPlayer(v);
    v.setMediaController(ctrlr);
    v.requestFocus();
    v.start();
  }
Exemplo n.º 16
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Get the layout from video_main.xml
    setContentView(R.layout.activity_videoview);
    // Find your VideoView in your video_main.xml layout
    videoview = (VideoView) findViewById(R.id.VideoView);
    // Execute StreamVideo AsyncTask

    // Create a progressbar
    pDialog = new ProgressDialog(VideoViewActivity.this);
    // Set progressbar title
    pDialog.setTitle("Android Video Streaming Tutorial");
    // Set progressbar message
    pDialog.setMessage("Buffering...");
    pDialog.setIndeterminate(false);
    pDialog.setCancelable(false);
    // Show progressbar
    pDialog.show();

    try {
      // Start the MediaController
      MediaController mediacontroller = new MediaController(VideoViewActivity.this);
      mediacontroller.setAnchorView(videoview);
      // Get the URL from String VideoURL
      Uri video = Uri.parse(VideoURL);
      videoview.setMediaController(mediacontroller);
      videoview.setVideoURI(video);

    } catch (Exception e) {
      Log.e("Error", e.getMessage());
      e.printStackTrace();
    }

    videoview.requestFocus();
    videoview.setOnPreparedListener(
        new OnPreparedListener() {
          // Close the progress bar and play the video
          public void onPrepared(MediaPlayer mp) {
            pDialog.dismiss();
            videoview.start();
          }
        });
  }
Exemplo n.º 17
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_video, container, false);

    // установите свой путь к файлу на SD-карточке

    // String videoSource ="/sdcard/Video/ana.mpeg";
    // String videoSource ="https://cs542300.vk.me/2/u3400922/videos/d65c5d132b.720.mp4";
    String videoSource =
        "http://cs540502v4.vk.me/u82858868/videos/0aca1f977d.360.mp4?extra=1pIvbmxIm5El_bz8qxozTvET5GOipetrjXrc-IzVbRO5P2mdimhmKG7EoVjiiRlS_ajloEzCU-RQhxFTMh7lHFtyqdibx-oG8g";
    // http://www.androidbegin.com/tutorial/AndroidCommercial.3gp

    final VideoView video = (VideoView) rootView.findViewById(R.id.videoView);

    MediaController mediaController = new MediaController(getActivity());
    mediaController.setAnchorView(video);

    video.setVideoURI(Uri.parse(videoSource));
    video.setMediaController(mediaController);

    video.requestFocus();
    video.start();

    /*final MediaController mMediaController = new MediaController(getActivity(), false);

    video.setOnPreparedListener( new MediaPlayer.OnPreparedListener() {

        @Override
        public void onPrepared(MediaPlayer pMp) {
            mMediaController.show();
        }

    });

    video.setMediaController(mMediaController);
    mMediaController.setMediaPlayer(video);
    video.setVideoPath(videoSource);  // may not be applicable in your case
    video.requestFocus();
    video.start();*/

    // Inflate the layout for this fragment
    return rootView;
  }
Exemplo n.º 18
0
  @Override
  public void onResume() {
    super.onResume();
    // ReceiverをRegister
    IntentFilter mIntentFilter = new IntentFilter();
    mIntentFilter.addAction(VideoConst.SEND_HOSTDP_TO_VIDEOPLAYER);
    registerReceiver(mReceiver, mIntentFilter);

    MediaController mMediaController = new MediaController(this);
    mMediaController.setAnchorView(mVideoView);

    mVideoView.setMediaController(mMediaController);
    mVideoView.setKeepScreenOn(true);
    mVideoView.setVideoURI(mUri);
    mVideoView.requestFocus();
    mVideoView.setOnCompletionListener(this);

    mVideoView.start();
  }
Exemplo n.º 19
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    this.getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.video_playback_layout);

    String path = getIntent().getExtras().getString(VideoList.VIDEO_EXTRA);
    File video = new File(path);
    if (!(video.exists())) throw new RuntimeException("Video Does not exist: " + path);

    VideoView videoView = (VideoView) findViewById(R.id.video_spot);
    MediaController mediaController = new MediaController(this);
    mediaController.setAnchorView(videoView);
    videoView.setMediaController(mediaController);
    videoView.setVideoPath(video.getAbsolutePath());
  }
Exemplo n.º 20
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_player);

    mVideo = (Video) getIntent().getSerializableExtra(Video.INTENT_EXTRA_VIDEO);

    View root = findViewById(R.id.root);
    mediaController = new MediaController(this);

    // overscan safe on 1980 * 1080 TV
    mediaController.setPadding(48, 27, 48, 27);
    mediaController.setAnchorView(root);
    shutterView = findViewById(R.id.shutter);
    surfaceView = (VideoSurfaceView) findViewById(R.id.surface_view);
    surfaceView.getHolder().addCallback(this);

    preparePlayer();
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    VIDEO_URL =
        "http://stream-1.vdomax.com:1935/vod/__definst__/mp4:youlove/youlove_xxx_7043.mp4/playlist.m3u8";

    setContentView(R.layout.player_activity);
    View root = findViewById(R.id.root);
    root.setOnTouchListener(
        new OnTouchListener() {
          @Override
          public boolean onTouch(View view, MotionEvent motionEvent) {
            if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
              toggleControlsVisibility();
            } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
              view.performClick();
            }
            return true;
          }
        });
    root.setOnKeyListener(
        new OnKeyListener() {
          @Override
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) {
              return mediaController.dispatchKeyEvent(event);
            }
            return false;
          }
        });
    audioCapabilitiesReceiver = new AudioCapabilitiesReceiver(getApplicationContext(), this);

    surfaceView = (VideoSurfaceView) findViewById(R.id.surface_view);
    surfaceView.getHolder().addCallback(this);

    mediaController = new MediaController(this);
    mediaController.setAnchorView(root);

    preparePlayer();

    // DemoUtil.setDefaultCookieManager();
  }
Exemplo n.º 22
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Get the layout from video_main.xml
    setContentView(R.layout.videoview_main);

    final VideoView mVideoView = (VideoView) findViewById(R.id.VideoView);
    mVideoView.setVideoPath(VideoURL);
    MediaController mediaController = new MediaController(this);
    mediaController.setAnchorView(mVideoView);
    // mVideoView.setMediaController(mediaController);
    mVideoView.requestFocus();
    mVideoView.setOnPreparedListener(
        new OnPreparedListener() {
          // Close the progress bar and play the video
          public void onPrepared(MediaPlayer mp) {
            mVideoView.start();
          }
        });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main_video);
    videoURL = getIntent().getStringExtra("url");
    txt_Title = getIntent().getStringExtra("title");
    txtDate = getIntent().getStringExtra("date");
    txtID = getIntent().getStringExtra("id");
    act_tag = getIntent().getIntExtra("tag", 1);

    setFindViewById();
    setEventWidget();
    setLayout();

    mVideoController = new MediaController(this);
    mVideoController.setAnchorView(VideoPlayer);
    VideoPlayer.setMediaController(mVideoController);

    setVideoPlayer(videoURL);
  }
Exemplo n.º 24
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.play_video_voa);

    StructureListAudioVoa cate =
        (StructureListAudioVoa) getIntent().getExtras().getBundle("audio").getParcelable("audio");
    videoview = (VideoView) findViewById(R.id.videoview);
    mediacontroller = new MediaController(WatchVideoVOA.this);
    mediacontroller.setAnchorView(videoview);

    videoview.setMediaController(mediacontroller);

    videoview.setVideoURI(Uri.parse(cate.getLink()));
    videoview.requestFocus();
    videoview.start();
  }
Exemplo n.º 25
0
  public void onPrepared(MediaPlayer mp) {
    Log.v(LOGTAG, "onPrepared Called");
    videoWidth = mp.getVideoWidth();
    videoHeight = mp.getVideoHeight();

    // 스크린 사이즈 구하기
    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int screenWidth = metrics.widthPixels;
    int screenHeight = metrics.heightPixels;

    if (videoWidth > screenWidth || videoHeight > screenHeight) {
      float heightRatio = (float) videoHeight / (float) screenHeight;
      float widthRatio = (float) videoWidth / (float) screenWidth;

      if (heightRatio > 1 || widthRatio > 1) {
        if (heightRatio > widthRatio) {
          videoHeight = (int) Math.ceil((float) videoHeight / (float) heightRatio);
          videoWidth = (int) Math.ceil((float) videoWidth / (float) heightRatio);
        } else {
          videoHeight = (int) Math.ceil((float) videoHeight / (float) widthRatio);
          videoWidth = (int) Math.ceil((float) videoWidth / (float) widthRatio);
        }
      }
    } else {
      videoHeight = screenHeight;
      videoWidth = screenWidth;
    }

    // surfaceView.setLayoutParams(new FrameLayout.LayoutParams(videoWidth,
    // videoHeight - 75));
    mp.start();

    // 미디어 플레이어의 컨트롤러를 설정하고 보이기
    controller.setMediaPlayer(this);
    controller.setAnchorView(this.findViewById(R.id.controllerView));
    controller.setEnabled(true);
    controller.show();
  }
Exemplo n.º 26
0
  @SuppressLint("NewApi")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.avideo);
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
      if (!BuildVars.debug) {
        getWindow().setFlags(LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE);
      }
    }
    NotificationManager mNotificationManager =
        (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.cancelAll();
    prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    title = (TextView) findViewById(R.id.tvVtitle);
    reports = new Reports(getApplicationContext(), "Training");
    mtitle = (TextView) findViewById(R.id.mtitle);
    icon = (ImageView) findViewById(R.id.miconimage);
    detail = (TextView) findViewById(R.id.tvVDetail);
    from = (TextView) findViewById(R.id.tvVFrom);
    summary = (TextView) findViewById(R.id.tvVsummary);
    vfullscreenplay = (ImageView) findViewById(R.id.vfullscreenplay);

    vid = (com.sanofi.in.mobcast.CustomVideoView) findViewById(R.id.vvType);

    mtitle.setText("Training");

    icon.setImageResource(R.drawable.training);

    // share = (Button) findViewById(R.id.bVshare);
    vid.setOnPreparedListener(this);
    btn = (ImageView) findViewById(R.id.vbackground);
    play = (ImageView) findViewById(R.id.vbackgroundplay);
    play.setOnClickListener(BackgroundclkListener);
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
      play.setAlpha(0.7f);
    }

    btn.setOnClickListener(BackgroundclkListener);

    share = (Button) findViewById(R.id.iv6);

    onNewIntent(getIntent());
    share.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub
            if (event.getAction() == android.view.MotionEvent.ACTION_DOWN) {
              if (android.os.Build.VERSION.SDK_INT >= 11) {
                v.setAlpha(0.5f);
              }
              // v.getBackground().setAlpha(45);
            } else if (event.getAction() == android.view.MotionEvent.ACTION_UP) {
              if (android.os.Build.VERSION.SDK_INT >= 11) {
                v.setAlpha(1);
              }
              // v.getBackground().setAlpha(255);
            }
            return false;
          }
        });
    vfullscreenplay.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            // isToRate = true;
            vid.pause();
            time = vid.getCurrentPosition();
            Log.d("Paused at ", "" + time);
            Intent i = new Intent(TrainingVideo.this, VideoFullscreen.class);
            i.putExtra("name", name);
            Log.d("name", name);
            i.putExtra("StartAt", (int) time);
            onDestroy();
            startActivity(i);
          }
        });

    detail.setText(DateUtils.formatDate(Ddetail));
    share.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            reports.updateShare(aid);
            final Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
            shareIntent.setType("video/mp4");
            String shareBody =
                title.getText()
                    + "\n"
                    + from.getText()
                    + "\n ON: "
                    + detail.getText()
                    + "\n"
                    + summary.getText();
            shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, title.getText());
            prefs.edit().putInt("StartAt", vid.getCurrentPosition()).commit();
            shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
            shareIntent.putExtra(android.content.Intent.EXTRA_STREAM, Uri.fromFile(file));
            startActivity(Intent.createChooser(shareIntent, "Share video"));
          }
        });

    String roo1t =
        Environment.getExternalStorageDirectory().toString() + Constants.APP_FOLDER_VIDEO + name;
    Bitmap thumbnail =
        ThumbnailUtils.createVideoThumbnail(roo1t, MediaStore.Images.Thumbnails.MINI_KIND);
    BitmapDrawable bitmapDrawable = new BitmapDrawable(thumbnail);
    vid.setBackgroundDrawable(bitmapDrawable);
    // btn.setBackgroundDrawable(bitmapDrawable);

    btn.setImageDrawable(bitmapDrawable);
    vid.setVideoPath(roo1t);

    mc = new MediaController(this);
    mc.show(500000);
    mc.setAnchorView(vid);
    vid.setMediaController(mc);
    vid.requestFocus();
    // vid.setPlayPauseListener(ppl);

  }
Exemplo n.º 27
0
  @Override
  protected void initView() {
    FrameLayout videoRoot = new FrameLayout(mContext);
    videoRoot.setBackgroundColor(WXResourceUtils.getColor("#ee000000"));

    mVideoView = new WXVideoView(mContext);
    FrameLayout.LayoutParams videoLayoutParams =
        new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
    videoLayoutParams.gravity = Gravity.CENTER;
    mVideoView.setLayoutParams(videoLayoutParams);
    videoRoot.addView(mVideoView);

    mProgressBar = new ProgressBar(mContext);
    FrameLayout.LayoutParams pLayoutParams =
        new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
    mProgressBar.setLayoutParams(pLayoutParams);
    pLayoutParams.gravity = Gravity.CENTER;
    videoRoot.addView(mProgressBar);

    final MediaController controller = new MediaController(mContext);

    controller.setAnchorView(videoRoot);

    mVideoView.setOnErrorListener(
        new MediaPlayer.OnErrorListener() {

          @Override
          public boolean onError(MediaPlayer mp, int what, int extra) {
            if (WXEnvironment.isApkDebugable()) {
              WXLogUtils.d("Video", "onError:" + what);
            }
            mProgressBar.setVisibility(View.GONE);
            mPrepared = false;
            mError = true;

            if (mDomObj.event != null && mDomObj.event.contains(WXEventType.VIDEO_FAIL)) {
              WXSDKManager.getInstance().fireEvent(mInstanceId, getRef(), WXEventType.VIDEO_FAIL);
            }
            return true;
          }
        });

    mVideoView.setOnPreparedListener(
        new MediaPlayer.OnPreparedListener() {

          @Override
          public void onPrepared(MediaPlayer mediaPlayer) {
            if (WXEnvironment.isApkDebugable()) {
              WXLogUtils.d("Video", "onPrepared");
            }
            mProgressBar.setVisibility(View.GONE);
            mPrepared = true;
            if (mAutoPlay) {
              mVideoView.start();
            }
            mVideoView.seekTo(5);
            if (!mStopped) {
              controller.show(3);
            } else {
              controller.hide();
            }
            mStopped = false;
          }
        });

    mVideoView.setOnCompletionListener(
        new MediaPlayer.OnCompletionListener() {

          @Override
          public void onCompletion(MediaPlayer mediaPlayer) {
            if (WXEnvironment.isApkDebugable()) {
              WXLogUtils.d("Video", "onCompletion");
            }
            if (mDomObj.event != null && mDomObj.event.contains(WXEventType.VIDEO_FINISH)) {
              WXSDKManager.getInstance().fireEvent(mInstanceId, getRef(), WXEventType.VIDEO_FINISH);
            }
          }
        });

    mVideoView.setOnVideoPauseListener(
        new WXVideoView.VideoPlayListener() {

          @Override
          public void onPause() {
            if (WXEnvironment.isApkDebugable()) {
              WXLogUtils.d("Video", "onPause");
            }
            if (mDomObj.event != null && mDomObj.event.contains(WXEventType.VIDEO_PAUSE)) {
              WXSDKManager.getInstance().fireEvent(mInstanceId, getRef(), WXEventType.VIDEO_PAUSE);
            }
          }

          @Override
          public void onStart() {
            if (WXEnvironment.isApkDebugable()) {
              WXLogUtils.d("Video", "onStart");
            }

            if (mDomObj.event != null && mDomObj.event.contains(WXEventType.VIDEO_START)) {
              WXSDKManager.getInstance().fireEvent(mInstanceId, getRef(), WXEventType.VIDEO_START);
            }
          }
        });

    mVideoView.setMediaController(controller);
    controller.setMediaPlayer(mVideoView);

    mHost = videoRoot;
  }
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    if (!io.vov.vitamio.LibsChecker.checkVitamioLibs(this)) return;

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    extras = getIntent().getExtras();

    // handle extras
    if (extras == null) {
      wrapItUp(RESULT_CANCELED, "Error: No options provided");
    } else {
      if (extras.containsKey("isStreaming")) {
        isStreaming = extras.getBoolean("isStreaming");
      }

      if (extras.containsKey("shouldAutoClose")) {
        mShouldAutoClose = extras.getBoolean("shouldAutoClose");
      }

      mMediaType = extras.getString("type");
      if (mMediaType == null) mMediaType = MEDIA_TYPE_VIDEO;

      mMediaPlayer = new MediaPlayer(this);
      mMediaController = new MediaController(this, !isStreaming);
      mMediaController.setMediaPlayer(this);
      mMediaPlayer.setOnBufferingUpdateListener(this);
      mMediaPlayer.setOnCompletionListener(this);
      mMediaPlayer.setOnErrorListener(this);
      mMediaPlayer.setOnPreparedListener(this);
      mMediaPlayer.setOnVideoSizeChangedListener(this);
      setVolumeControlStream(AudioManager.STREAM_MUSIC);

      RelativeLayout relLayout = new RelativeLayout(this);

      if (extras.containsKey("bgColor")) {
        try {
          bgColor = Color.parseColor(extras.getString("bgColor"));
        } catch (Exception e) {
          Log.v(TAG, "Error parsing color");
          Log.e(TAG, e.toString());
          bgColor = DEFAULT_BG_COLOR;
        }
      }
      relLayout.setBackgroundColor(bgColor);

      RelativeLayout.LayoutParams relLayoutParam =
          new RelativeLayout.LayoutParams(
              RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
      relLayoutParam.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
      mMediaView = new SurfaceView(this);
      mMediaView.setLayoutParams(relLayoutParam);
      relLayout.addView(mMediaView);

      mProgressBar = new ProgressBar(this);
      mProgressBar.setIndeterminate(true);
      mProgressBar.setVisibility(View.VISIBLE);
      RelativeLayout.LayoutParams pblp =
          new RelativeLayout.LayoutParams(
              RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
      pblp.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
      mProgressBar.setLayoutParams(pblp);
      relLayout.addView(mProgressBar);
      mProgressBar.bringToFront();

      mMediaController.setAnchorView(relLayout);
      mMediaController.setEnabled(true);
      if (mMediaType.equalsIgnoreCase(MEDIA_TYPE_AUDIO)) {
        mMediaView.setBackgroundColor(bgColor);
        if (extras.containsKey("bgImage")) {
          if (extras.containsKey("bgImageScaleType")) {
            String scaleType = extras.getString("bgImageScaleType");
            if (scaleType.equalsIgnoreCase("fit")) {
              bgImageScaleType = ImageView.ScaleType.FIT_CENTER;
            } else if (scaleType.equalsIgnoreCase("stretch")) {
              bgImageScaleType = ImageView.ScaleType.FIT_XY;
            } else {
              bgImageScaleType = ImageView.ScaleType.CENTER;
            }
          }
          bgImage = new ImageView(this);
          new ImageLoadTask(extras.getString("bgImage"), this).execute(null, null);
          RelativeLayout.LayoutParams bgImageLayoutParam =
              new RelativeLayout.LayoutParams(
                  RelativeLayout.LayoutParams.MATCH_PARENT,
                  RelativeLayout.LayoutParams.MATCH_PARENT);
          bgImageLayoutParam.addRule(RelativeLayout.CENTER_IN_PARENT);
          bgImage.setLayoutParams(bgImageLayoutParam);
          bgImage.setScaleType(bgImageScaleType);
          relLayout.addView(bgImage);
        }
      }
      setContentView(relLayout, relLayoutParam);
      holder = mMediaView.getHolder();
      holder.addCallback(this);
      holder.setFormat(PixelFormat.RGBA_8888);
    }
  }
  @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);
          }
        });
  }
Exemplo n.º 30
0
 @Override
 public void setAnchorView(View view) {
   mMediaController.setAnchorView(view);
 }