Java Code Examples for android.widget.VideoView

The following are top voted examples for showing how to use android.widget.VideoView. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: apps_small   File: MainActivity.java   View source code 7 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Find the video view by id so we can use it.
    VideoView myVideo = (VideoView) findViewById(R.id.videoView);

    // To set the path to the video. Sample.mp4 is in the "raw" folder.
    // You can use http://online.path.to.your.video also.
    myVideo.setVideoPath("android.resource://" + getPackageName() + "/" + R.raw.sample);

    // To create the media controller (play, pause, etc.)
    MediaController myController = new MediaController(this);

    // To link the media controller to the video view.
    myController.setAnchorView(myVideo);

    // To link the video view to the media controller.
    myVideo.setMediaController(myController);

    // To autoplay on opening.
    myVideo.start();

}
 
Example 2
Project: NotifyTools   File: MainActivity.java   View source code 6 votes vote down vote up
@Override

        protected void onCreate(Bundle savedInstanceState) {

            super.onCreate(savedInstanceState);
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);//强制竖屏
            final VideoView vv=new VideoView(this.getContext());
            RelativeLayout rlmain=new RelativeLayout(this.getContext());
            this.setContentView(vv);
            TextView txt=new TextView(rlmain.getContext());
            rlmain.addView(txt);
            txt.setText("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
//            rlmain.setBackgroundColor(Color.RED);
            vv.setVideoPath("/sdcard/mwwyt.mpg");
            vv.start();

            vv.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
                @Override
                public void onCompletion(MediaPlayer mp) {
                    vv.start();
                }
            });


        }
 
Example 3
Project: AndroidBookTest   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    videoView=(VideoView)findViewById(R.id.video_view);
    Button play=(Button)findViewById(R.id.play);
    Button pause=(Button)findViewById(R.id.pause);
    Button replay=(Button)findViewById(R.id.replay);
    play.setOnClickListener(this);
    pause.setOnClickListener(this);
    replay.setOnClickListener(this);
    if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.
            WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED){
        ActivityCompat.requestPermissions(MainActivity.this,new String[]{
                Manifest.permission.WRITE_EXTERNAL_STORAGE},1);
    }else {
        initVideoPath();//初始化VideoView
    }
}
 
Example 4
Project: PLDroidShortVideo   File: VideoTrimActivity.java   View source code 6 votes vote down vote up
private void init(String videoPath) {
    setContentView(R.layout.activity_trim);
    TextView duration = (TextView) findViewById(R.id.duration);
    mPreview = (VideoView) findViewById(R.id.preview);

    mShortVideoTrimmer = new PLShortVideoTrimmer(this, videoPath, Config.TRIM_FILE_PATH);
    mMediaFile = new PLMediaFile(videoPath);

    mSelectedEndMs = mDurationMs = mMediaFile.getDurationMs();
    duration.setText("时长: " + formatTime(mDurationMs));
    Log.i(TAG, "video duration: " + mDurationMs);

    mVideoFrameCount = mMediaFile.getVideoFrameCount(false);
    Log.i(TAG, "video frame count: " + mVideoFrameCount);

    mPreview.setVideoPath(videoPath);
    mPreview.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
        @Override
        public void onCompletion(MediaPlayer mediaPlayer) {
            play();
        }
    });

    initVideoFrameList();
}
 
Example 5
Project: mpeg-encoder   File: MainActivity.java   View source code 6 votes vote down vote up
/** {@inheritDoc} */
@Override
protected final void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mContentView = new VideoView(this);
    mContentView.setVisibility(View.GONE);
    mContentView.setOnPreparedListener(new OnPreparedListener());

    final FrameLayout.LayoutParams layoutParams =
            new FrameLayout.LayoutParams(
                    FrameLayout.LayoutParams.WRAP_CONTENT,
                    FrameLayout.LayoutParams.WRAP_CONTENT,
                    Gravity.CENTER);
    mContentView.setLayoutParams(layoutParams);

    setContentView(mContentView);

    startEncode(new File(getFilesDir(), OUTPUT_FILE_NAME).getAbsolutePath());
}
 
Example 6
Project: AndroidFFmpegCompress   File: VideoPlayerActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    VideoView videoView = new VideoView(this);
    setContentView(videoView);
    videoView.setMediaController(new MediaController(this));
    videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
        @Override
        public void onCompletion(MediaPlayer mp) {
            Toast.makeText( VideoPlayerActivity.this, "播放完成了", Toast.LENGTH_SHORT).show();
        }
    });
    String videoPath = getIntent().getStringExtra("videoPath");
    try {
        videoView.setVideoPath(videoPath);
        videoView.start();
    } catch (Exception e) {
        e.printStackTrace();
        Toast.makeText(VideoPlayerActivity.this, "视频不存在", Toast.LENGTH_SHORT).show();
    }
}
 
Example 7
Project: LifeSaver   File: Main4Activity.java   View source code 6 votes vote down vote up
private void go() {
VideoView v=(VideoView)findViewById(R.id.videoView) ;
        final ProgressBar p=(ProgressBar)findViewById(R.id.progressBar3);
        v.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mp) {
                p.setVisibility(View.GONE);
            }
        });
        String s="https://firebasestorage.googleapis.com/v0/b/lifesaver-18f28.appspot.com/o/flood.mp4?alt=media&token=179d7e4e-7171-4a87-b1f8-b1fc3d976c60";
        Uri uri=Uri.parse(s);
        v.setVideoURI(uri);
        v.setVideoPath(s);
        v.requestFocus();
        v.start();


    }
 
Example 8
Project: LifeSaver   File: Main3Activity.java   View source code 6 votes vote down vote up
private void go() {
        final ProgressBar p=(ProgressBar)findViewById(R.id.progressBar2);
        VideoView v=(VideoView)findViewById(R.id.videoView2) ;
v.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
    @Override
    public void onPrepared(MediaPlayer mp) {
        p.setVisibility(View.GONE);
    }
});
String s="https://firebasestorage.googleapis.com/v0/b/lifesaver-18f28.appspot.com/o/earthquake.mp4?alt=media&token=98993371-823d-4b81-adc7-d9d87ec841a9";
        Uri uri=Uri.parse(s);
        v.setVideoURI(uri);
         v.setVisibility(View.VISIBLE);
         v.setVideoPath(s);
        v.requestFocus();
        v.start();





    }
 
Example 9
Project: boohee_v5.6   File: VideoPlayerManager.java   View source code 6 votes vote down vote up
public static void initPlayer(VideoView videoView, OnPreparedListener onPreparedListener,
                              OnCompletionListener onCompletionListener, OnErrorListener
                                      onErrorListener) {
    if (onPreparedListener != null) {
        videoView.setOnPreparedListener(onPreparedListener);
    }
    if (onCompletionListener != null) {
        videoView.setOnCompletionListener(onCompletionListener);
    }
    if (onErrorListener != null) {
        videoView.setOnErrorListener(onErrorListener);
    }
}
 
Example 10
Project: boohee_v5.6   File: MentionPreviewActivity$$ViewInjector.java   View source code 6 votes vote down vote up
public void inject(Finder finder, final T target, Object source) {
    target.progressBar = (ProgressWheel) finder.castView((View) finder.findRequiredView
            (source, R.id.progress_bar, "field 'progressBar'"), R.id.progress_bar, "field " +
            "'progressBar'");
    target.progressLayout = (RelativeLayout) finder.castView((View) finder.findRequiredView
            (source, R.id.progress_layout, "field 'progressLayout'"), R.id.progress_layout,
            "field 'progressLayout'");
    View view = (View) finder.findRequiredView(source, R.id.btn_close, "field 'btnClose' and " +
            "method 'onClick'");
    target.btnClose = (ImageView) finder.castView(view, R.id.btn_close, "field 'btnClose'");
    view.setOnClickListener(new DebouncingOnClickListener() {
        public void doClick(View p0) {
            target.onClick(p0);
        }
    });
    target.videoView = (VideoView) finder.castView((View) finder.findRequiredView(source, R
            .id.video_view, "field 'videoView'"), R.id.video_view, "field 'videoView'");
    target.viewPager = (ViewPager) finder.castView((View) finder.findRequiredView(source, R
            .id.view_pager, "field 'viewPager'"), R.id.view_pager, "field 'viewPager'");
    target.tvIndex = (TextView) finder.castView((View) finder.findRequiredView(source, R.id
            .tv_index, "field 'tvIndex'"), R.id.tv_index, "field 'tvIndex'");
}
 
Example 11
Project: YCGallery   File: VideoPlayerActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    String url = getIntent().getExtras().getString(Constants.URL);
    setContentView(R.layout.fragment_video_gallery);
    final VideoView videoView = (VideoView) findViewById(R.id.videoView);
    videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mp) {
            View progress = findViewById(R.id.videoProgress);
            progress.setVisibility(View.GONE);

            videoView.requestFocus();
            MediaController vidControl = new MediaController(VideoPlayerActivity.this);
            vidControl.setAnchorView(videoView);
            videoView.setMediaController(vidControl);
            videoView.start();
        }
    });
    videoView.setVideoURI(Uri.parse(url));
}
 
Example 12
Project: EsperantoRadio   File: LocalPlayerActivity.java   View source code 6 votes vote down vote up
private void loadViews() {
    mVideoView = (VideoView) findViewById(R.id.videoView1);
    mTitleView = (TextView) findViewById(R.id.titleTextView);
    mDescriptionView = (TextView) findViewById(R.id.descriptionTextView);
    mDescriptionView.setMovementMethod(new ScrollingMovementMethod());
    mAuthorView = (TextView) findViewById(R.id.authorTextView);
    mStartText = (TextView) findViewById(R.id.startText);
    mStartText.setText(Utils.formatMillis(0));
    mEndText = (TextView) findViewById(R.id.endText);
    mSeekbar = (SeekBar) findViewById(R.id.seekBar1);
    mPlayPause = (ImageView) findViewById(R.id.playPauseImageView);
    mLoading = (ProgressBar) findViewById(R.id.progressBar1);
    mControllers = findViewById(R.id.controllers);
    mContainer = findViewById(R.id.container);
    mCoverArt = (ImageView) findViewById(R.id.coverArtView);
    ViewCompat.setTransitionName(mCoverArt, getString(R.string.transition_image));
    mPlayCircle = (ImageButton) findViewById(R.id.play_circle);
    mPlayCircle.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            togglePlayback();
        }
    });
}
 
Example 13
Project: minVideo   File: VideoActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_player);

    mVideoPath = getIntent().getStringExtra("videoPath");

    if (!TextUtils.isEmpty(mVideoPath)) {
        new RecentMediaStorage(this).saveUrlAsync(mVideoPath);
    }

    videoView = (VideoView) findViewById(R.id.view_video);

    android.widget.MediaController mediaController = new android.widget.MediaController(this);
    videoView.setMediaController(mediaController);
    videoView.setVideoPath(mVideoPath);
    videoView.start();
}
 
Example 14
Project: RLibrary   File: VideoPlayActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_video_play);

    enableLayoutFullScreen();

    mVideoView = (VideoView) findViewById(R.id.video_view);
    playView = (ImageView) findViewById(R.id.play_view);

    playView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            playView.setVisibility(View.GONE);
            mVideoView.start();
        }
    });

    String videoPath = getIntent().getStringExtra(KEY_VIDEO_PATH);

    mVideoView.setVideoPath(videoPath);
    mVideoView.start();

    mVideoView.setOnCompletionListener(this);
}
 
Example 15
Project: Touch-to-record-Camera   File: PreviewActivity.java   View source code 6 votes vote down vote up
private void init() {
    ivPlay = (ImageView) findViewById(R.id.previre_play);
    btDelete = (Button) findViewById(R.id.bt_cancel);
    ivImage = (ImageView) findViewById(R.id.iv_image);
    vvContent = (VideoView) findViewById(R.id.vv_content);

    ivPlay.setOnClickListener(this);
    btDelete.setOnClickListener(this);

    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inPreferredConfig = Bitmap.Config.ARGB_8888;
    Bitmap bitmap = BitmapFactory.decodeFile(imagePath, options);
    ivImage.setImageBitmap(bitmap);

    if (videoPath.equals("")) {
        ivPlay.setVisibility(View.GONE);
        vvContent.setVisibility(View.GONE);
    }
}
 
Example 16
Project: ChatUp   File: ChatFragment.java   View source code 6 votes vote down vote up
public MessageHolder(View view, int type) {
    super(view);
    mID = type;
    itemView.setOnLongClickListener(this);
    itemView.setOnClickListener(this);
    if (mID < 2)
        messageView = (TextView) itemView.findViewById(R.id.holder_text);
    else if (mID < 4) {
        mImageView = (SimpleDraweeView) itemView.findViewById(R.id.image_holder);
        //  mImageView.setOnClickListener(this);
    } else if (mID < 6)
        mVideoView = (VideoView) itemView.findViewById(R.id.video_holder);

    dateView = (TextView) itemView.findViewById(R.id.date);
    mStatusImageView = (ImageView) itemView.findViewById(R.id.status);
}
 
Example 17
Project: CastVideos-android   File: LocalPlayerActivity.java   View source code 6 votes vote down vote up
private void loadViews() {
    mVideoView = (VideoView) findViewById(R.id.videoView1);
    mTitleView = (TextView) findViewById(R.id.titleTextView);
    mDescriptionView = (TextView) findViewById(R.id.descriptionTextView);
    mDescriptionView.setMovementMethod(new ScrollingMovementMethod());
    mAuthorView = (TextView) findViewById(R.id.authorTextView);
    mStartText = (TextView) findViewById(R.id.startText);
    mStartText.setText(Utils.formatMillis(0));
    mEndText = (TextView) findViewById(R.id.endText);
    mSeekbar = (SeekBar) findViewById(R.id.seekBar1);
    mPlayPause = (ImageView) findViewById(R.id.playPauseImageView);
    mLoading = (ProgressBar) findViewById(R.id.progressBar1);
    mControllers = findViewById(R.id.controllers);
    mContainer = findViewById(R.id.container);
    mCoverArt = (ImageView) findViewById(R.id.coverArtView);
    ViewCompat.setTransitionName(mCoverArt, getString(R.string.transition_image));
    mPlayCircle = (ImageButton) findViewById(R.id.play_circle);
    mPlayCircle.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            togglePlayback();
        }
    });
}
 
Example 18
Project: android-lite   File: VideoActivity.java   View source code 6 votes vote down vote up
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_video);

    // Load the appropriate URL in the VideoView.
    final String youtubeId = getIntent().getStringExtra(Keys.YOUTUBE_ID);
    final String videoUrl = UrlBuilder.forYoutubeId(youtubeId);
    final VideoView videoView = (VideoView) findViewById(R.id.video_view);
    videoView.setVideoPath(videoUrl);
    videoView.start();

    // Add a MediaController, which gives us play/pause, etc.
    final MediaController mediaController = new MediaController(this);
    mediaController.setAnchorView(videoView);
    videoView.setMediaController(mediaController);
}
 
Example 19
Project: Marv   File: VideoFull.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.video_full);
    videofull=(VideoView)findViewById(R.id.videofull);
    videofull.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.video));
    videofull.setMediaController(new MediaController(VideoFull.this));
    videofull.start();
    videofull.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mp) {
            mp.setLooping(true);
        }
    });
    videofull.requestFocus();
}
 
Example 20
Project: Cirrus   File: PreviewMediaFragment.java   View source code 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    Log_OC.v(TAG, "onCreateView");

    mView = inflater.inflate(R.layout.file_preview, container, false);

    mImagePreview = (ImageView) mView.findViewById(R.id.image_preview);
    mVideoPreview = (VideoView) mView.findViewById(R.id.video_preview);
    mVideoPreview.setOnTouchListener(this);

    mMediaController = (MediaControlView) mView.findViewById(R.id.media_controller);

    return mView;
}
 
Example 21
Project: TDT-Spain   File: PlayerActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_player);
    videoView = (VideoView) findViewById(R.id.videoView);
    Intent i = getIntent();
    Bundle extras = i.getExtras();
    if (extras.getString(Constants.LABEL) != null && extras.getString(Constants.URL) != null) {
        url = extras.getString(Constants.URL);
        label = extras.getString(Constants.LABEL);

        play(label, url);
    }


}
 
Example 22
Project: mytarget-android   File: InstreamAdActivity.java   View source code 6 votes vote down vote up
public void startVideo(View view)
{
	if (instreamAd == null) return;
	videoView = new VideoView(this);
	FrameLayout.LayoutParams videoPlayerParams = new FrameLayout.LayoutParams(ViewGroup
			.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
	videoPlayerParams.gravity = Gravity.CENTER;
	videoFrame.addView(videoView, videoPlayerParams);
	playButton.setVisibility(View.GONE);

	FrameLayout.LayoutParams adPlayerParams = new FrameLayout.LayoutParams
			(ViewGroup.LayoutParams.MATCH_PARENT,
					ViewGroup.LayoutParams.WRAP_CONTENT);
	adPlayerParams.gravity = Gravity.CENTER;

	View adPlayerView = instreamAd.getPlayer().getView();
	if (adPlayerView.getParent() == null)
		videoFrame.addView(adPlayerView, adPlayerParams);

	instreamAdController.setSkipListener(this);
	instreamAdController.setAdClickListener(this);
	instreamAdController.setAnchorView(videoFrame);
	instreamAdController.setVisibility(View.VISIBLE);

	startPreroll();
}
 
Example 23
Project: AndroidFFmpegCMDTool   File: VideoProcessActivity.java   View source code 6 votes vote down vote up
private void initView() {
	tv_title = (TextView) findViewById(R.id.tv_videoProcessActivity_title);
	switch (processType) {
	case VALUE_GENERATION_GIF:
		tv_title.setText("生成GIF");
		break;
	case VALUE_GENERATION_PIC:
		tv_title.setText("生成连拍图");
		break;
	}
	
	videoView = (VideoView) findViewById(R.id.vv_videoProcessActivity);
	pb_video = (ProgressBar) findViewById(R.id.pb_videoProcessActivity_video);
	
	horizontalScrollView = (GPHorizontalScrollView) findViewById(R.id.hsv_videoProcessActivity);
	horizontalScrollView.setListener(new MyGPHorizontalScrollViewListener());
	layout_thumbnail = (LinearLayout) findViewById(R.id.layout_videoProcessActivity_thumbnail);
	layout_thumbnail.removeAllViews();
}
 
Example 24
Project: cast-videos-android   File: LocalPlayerActivity.java   View source code 6 votes vote down vote up
private void loadViews() {
    mVideoView = (VideoView) findViewById(R.id.videoView1);
    mTitleView = (TextView) findViewById(R.id.textView1);
    mDescriptionView = (TextView) findViewById(R.id.textView2);
    mDescriptionView.setMovementMethod(new ScrollingMovementMethod());
    mAuthorView = (TextView) findViewById(R.id.textView3);
    mStartText = (TextView) findViewById(R.id.startText);
    mStartText.setText(Utils.formatMillis(0));
    mEndText = (TextView) findViewById(R.id.endText);
    mSeekbar = (SeekBar) findViewById(R.id.seekBar1);
    mPlayPause = (ImageView) findViewById(R.id.imageView2);
    mLoading = (ProgressBar) findViewById(R.id.progressBar1);
    mControllers = findViewById(R.id.controllers);
    mContainer = findViewById(R.id.container);
    mCoverArt = (ImageView) findViewById(R.id.coverArtView);
    ViewCompat.setTransitionName(mCoverArt, getString(R.string.transition_image));
    mPlayCircle = (ImageButton) findViewById(R.id.play_circle);
    mPlayCircle.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            togglePlayback();
        }
    });
}
 
Example 25
Project: cast-videos-android   File: LocalPlayerActivity.java   View source code 6 votes vote down vote up
private void loadViews() {
    mVideoView = (VideoView) findViewById(R.id.videoView1);
    mTitleView = (TextView) findViewById(R.id.textView1);
    mDescriptionView = (TextView) findViewById(R.id.textView2);
    mDescriptionView.setMovementMethod(new ScrollingMovementMethod());
    mAuthorView = (TextView) findViewById(R.id.textView3);
    mStartText = (TextView) findViewById(R.id.startText);
    mStartText.setText(Utils.formatMillis(0));
    mEndText = (TextView) findViewById(R.id.endText);
    mSeekbar = (SeekBar) findViewById(R.id.seekBar1);
    mPlayPause = (ImageView) findViewById(R.id.imageView2);
    mLoading = (ProgressBar) findViewById(R.id.progressBar1);
    mControllers = findViewById(R.id.controllers);
    mContainer = findViewById(R.id.container);
    mCoverArt = (ImageView) findViewById(R.id.coverArtView);
    ViewCompat.setTransitionName(mCoverArt, getString(R.string.transition_image));
    mPlayCircle = (ImageButton) findViewById(R.id.play_circle);
    mPlayCircle.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            togglePlayback();
        }
    });
}
 
Example 26
Project: ScrollGallery-android   File: VideoPlayerActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    String url = getIntent().getExtras().getString(Constants.URL);
    setContentView(R.layout.video_fragment);
    final VideoView videoView = (VideoView) findViewById(R.id.videoView);
    videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mp) {
            View progress = findViewById(R.id.videoProgress);
            progress.setVisibility(View.GONE);

            videoView.requestFocus();
            MediaController vidControl = new MediaController(VideoPlayerActivity.this);
            vidControl.setAnchorView(videoView);
            videoView.setMediaController(vidControl);
            videoView.start();
        }
    });
    videoView.setVideoURI(Uri.parse(url));
}
 
Example 27
Project: bullseye   File: PreviewActivity.java   View source code 6 votes vote down vote up
private void init() {
    ivPlay = (ImageView) findViewById(R.id.previre_play);
    ivDelete = (ImageView) findViewById(R.id.bt_cancel);
    ivPhoto = (ImageView) findViewById(R.id.iv_photo);
    vvContent = (VideoView) findViewById(R.id.vv_content);
    btNext = (Button) findViewById(R.id.bt_ok);
    rlBottom = (RelativeLayout) findViewById(R.id.rl_bottom);

    ivPlay.setOnClickListener(this);
    ivDelete.setOnClickListener(this);
    btNext.setOnClickListener(this);

    ivPlay.setImageResource(previewPlayIcon);
    ivDelete.setImageResource(previewTrashIcon);
    rlBottom.setBackgroundColor(ContextCompat.getColor(this,themeColor));

    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inPreferredConfig = Bitmap.Config.ARGB_8888;
    Bitmap bitmap = BitmapFactory.decodeFile(imagePath, options);
    ivPhoto.setImageBitmap(bitmap);

    if (videoPath.equals("")) {
        ivPlay.setVisibility(View.GONE);
        vvContent.setVisibility(View.GONE);
    }
}
 
Example 28
Project: bullseye   File: PreviewFragment.java   View source code 6 votes vote down vote up
private void init() {
    ivPlay = (ImageView) view.findViewById(R.id.previre_play);
    ivDelete = (ImageView) view.findViewById(R.id.bt_cancel);
    ivPhoto = (ImageView) view.findViewById(R.id.iv_photo);
    vvContent = (VideoView) view.findViewById(R.id.vv_content);
    btNext = (Button) view.findViewById(R.id.bt_ok);
    rlBottom = (RelativeLayout) view.findViewById(R.id.rl_bottom);

    ivPlay.setOnClickListener(this);
    ivDelete.setOnClickListener(this);
    btNext.setOnClickListener(this);

    ivPlay.setImageResource(previewPlayIcon);
    ivDelete.setImageResource(previewTrashIcon);
    rlBottom.setBackgroundColor(ContextCompat.getColor(getActivity(),themeColor));

    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inPreferredConfig = Bitmap.Config.ARGB_8888;
    Bitmap bitmap = BitmapFactory.decodeFile(imagePath, options);
    ivPhoto.setImageBitmap(bitmap);

    if (videoPath.equals("")) {
        ivPlay.setVisibility(View.GONE);
        vvContent.setVisibility(View.GONE);
    }
}
 
Example 29
Project: EDSApp   File: VideoActivity.java   View source code 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PreferencesState.getInstance().loadsLanguageInActivity();
    setContentView(R.layout.video_activity);

    //Displays a video file.
    MediaController mediaController = new MediaController(VideoActivity.this);
    mVideoView = (VideoView)findViewById(R.id.videoview);
    String videoPathParam = getIntent().getStringExtra(VIDEO_PATH_PARAM);
    mVideoView.setVideoPath(videoPathParam);
    mVideoView.setMediaController(mediaController);
    mediaController.setAnchorView(mVideoView);

    mVideoView.requestFocus();
    if (savedInstanceState != null) {
        mVideoView.seekTo(savedInstanceState.getInt("video",0));
    }
    mVideoView.start();
}
 
Example 30
Project: youkes_vr   File: SideBySideVideoPlayActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_side_by_side);
    //Utils.setActionBarSubtitleEllipsizeMiddle(this);

    mAndroidVideoView = (android.widget.VideoView) findViewById(R.id.androidvv);
    mItecVideoView = (VideoView) findViewById(R.id.itecvv);

    mMediaPlayerControl = new MediaPlayerMultiControl(mAndroidVideoView, mItecVideoView);
    mMediaController = new MediaController(this);
    mMediaController.setAnchorView(findViewById(R.id.container));
    mMediaController.setMediaPlayer(mMediaPlayerControl);

    mPath = getIntent().getStringExtra("play");
    mTitle = getIntent().getStringExtra("play");
    if(StringUtils.isHttp(mPath)) {
        if (!checkWifi()) {
            ToastUtil.showMessage(getString(R.string.network_waste));
            wifiStateDlg();
            return;
        }
    }

    loadVideo();
}
 
Example 31
Project: faims-android   File: FileGalleryPreviewDialog.java   View source code 6 votes vote down vote up
public void addVideoPreview(View view) {
	if (view instanceof VideoView) {
		videoView = (VideoView) view;
	}
	
	TabHost.TabSpec tab = tabHost.newTabSpec("video_preview");
	tab.setIndicator("Video Preview");
	tab.setContent(new TabContentFactory() {
		
		@Override
		public View createTabContent(String tag) {
			LinearLayout layout = new LinearLayout(getContext());
			layout.setOrientation(LinearLayout.VERTICAL);
			
			layout.addView(videoView, new LayoutParams(LayoutParams.MATCH_PARENT,
					LayoutParams.MATCH_PARENT));
			
			return layout;
		}
	});
	tabHost.addTab(tab);
}
 
Example 32
Project: galactic-tavern-android   File: VideoPlayerActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    String url = getIntent().getExtras().getString(Constants.URL);
    setContentView(R.layout.video_fragment);
    final VideoView videoView = (VideoView) findViewById(R.id.videoView);
    videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mp) {
            View progress = findViewById(R.id.videoProgress);
            progress.setVisibility(View.GONE);

            videoView.requestFocus();
            MediaController vidControl = new MediaController(VideoPlayerActivity.this);
            vidControl.setAnchorView(videoView);
            videoView.setMediaController(vidControl);
            videoView.start();
        }
    });
    videoView.setVideoURI(Uri.parse(url));
}
 
Example 33
Project: DexShiftingView   File: ContentFragment.java   View source code 6 votes vote down vote up
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    swipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_container);
    swipeRefreshLayout.setOnRefreshListener(this);
    swipeRefreshLayout.setColorSchemeColors(getResources().getColor(R.color.primary));
    DexShiftingLayout dexShiftingView = (DexShiftingLayout) view.findViewById(R.id.dexshiftingview);
    dexShiftingView.setOnShiftListener(onShiftListener);
    dexShiftingView.setToolbar(onShiftListener.getToolbar(), getResources().getColor(R.color.primary), getResources().getColor(R.color.secondary));
    RecyclerView recyclerView = dexShiftingView.getScrollingView();
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    recyclerView.setAdapter(new TestAdapter());
    switch (subsection) {
        case VIDEO_VIEW:
            VideoView videoView = (VideoView) view.findViewById(R.id.video);
            videoView.setVideoURI(Uri.parse("android.resource://" + getActivity().getPackageName() + "/"
                    + R.raw.video));
            videoView.start();
            break;
    }
}
 
Example 34
Project: DexShiftingView   File: ContentPagerFragment.java   View source code 6 votes vote down vote up
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    adapter = new MyPagerAdapter(getChildFragmentManager());
    DexShiftingPagerLayout dexShiftingView = (DexShiftingPagerLayout) view.findViewById(R.id.dexshiftingview);
    dexShiftingView.setOnShiftListener(onShiftListener);
    dexShiftingView.setToolbar(onShiftListener.getToolbar(), getResources().getColor(R.color.primary), getResources().getColor(R.color.secondary));
    dexShiftingView.setAdapter(adapter);
    switch (subsection) {
        case VIDEO_VIEW:
            VideoView videoView = (VideoView) view.findViewById(R.id.video);
            videoView.setVideoURI(Uri.parse("android.resource://" + getActivity().getPackageName() + "/"
                    + R.raw.video));
            videoView.start();
            break;
    }
}
 
Example 35
Project: alternate-java-bridge-library   File: VideoPlayer.java   View source code 6 votes vote down vote up
/**
 * Creates a new VideoPlayer component.
 *
 * @param container
 */
public VideoPlayer(ComponentContainer container) {
  super(container);
  
  videoView = new VideoView(container.$context());
  videoView.setMediaController(new MediaController(container.$context()));
  videoView.setOnCompletionListener(this);
  videoView.setOnErrorListener(this);

  // add the component to the designated container
  container.$add(this);
  // set a default size
  container.setChildWidth(this, ComponentConstants.VIDEOPLAYER_PREFERRED_WIDTH);
  container.setChildHeight(this, ComponentConstants.VIDEOPLAYER_PREFERRED_HEIGHT);
  container.$form().registerForOnInitialize(this);
  sourcePath = "";
}
 
Example 36
Project: videoComparator   File: VideoComparatorActivity.java   View source code 6 votes vote down vote up
/**
 * Manages all the infos we got from the InfoListener from the two videos.
 * Have a look at registerVideoListeners where the InfoListeners are registered.
 *
 * @param videoView The video view which emitted the info.
 * @param what      The information constant. Corresponds to MediaPlayer.MEDIA_INFO_xxx
 * @return true if the information should be treated as handled (see InfoListener.onInfo).
 */
private boolean handleVideoInfo(VideoView videoView, int what) {
    boolean isHandled = false;
    switch (what) {
        //TODO: Think about implementing states: MediaPlayer.MEDIA_INFO_BUFFERING_START, MEDIA_INFO_BUFFERING_END
        case MediaPlayer.MEDIA_INFO_NOT_SEEKABLE:
            Log.i(TAG, getVideoViewNameForLogging(videoView) + " is not seekable");

            //Seek should be disabled
            if (videoView == video1) {
                VIDEO_PLAY_STATE.setVideo1Seekable(false);
            } else if (videoView == video2) {
                VIDEO_PLAY_STATE.setVideo2Seekable(false);
            }
            isHandled = true;
            break;

        default:
            isHandled = false;

    }

    return isHandled;
}
 
Example 37
Project: videoComparator   File: VideoComparatorActivity.java   View source code 6 votes vote down vote up
/**
 * (Un)loads a video in a video view.
 * As a side effect the currently loaded video is stored in VIDEO_PLAY_STATE
 *
 * @param videoToPlay The uri to be played. In case the uri is null the video is unloaded.
 * @param videoView   The video view in which to load the video.
 */
private void loadVideo(Uri videoToPlay, VideoView videoView) {
    if (videoToPlay == null) {
        //Unload video
        videoView.stopPlayback();
        videoView.setVideoURI(null);
    } else {
        //Load video
        videoView.setVideoURI(videoToPlay);
    }

    //Remember current video
    if (videoView == video1) {
        VIDEO_PLAY_STATE.setVideo1(videoToPlay);
        //initially a video is seekable. The media player will push an info in case this is not true.
        VIDEO_PLAY_STATE.setVideo1Seekable(videoToPlay != null);
    } else {
        VIDEO_PLAY_STATE.setVideo2(videoToPlay);

        //initially a video is seekable. The media player will push an info in case this is not true.
        VIDEO_PLAY_STATE.setVideo2Seekable(videoToPlay != null);
    }

    updateGuiState();
}
 
Example 38
Project: AudioVideo   File: MainFragment.java   View source code 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View myView = inflater.inflate(R.layout.fragment_main, container, false);
    mVideoView = (VideoView)myView.findViewById(R.id.videoView1);
    mVideoView.setMediaController(new MediaController(getActivity()));

    //setup the button take a video.
    Button btn1 = (Button)myView.findViewById(R.id.button1);
    btn1.setOnClickListener( new View.OnClickListener(){
        @Override
        public void onClick(View v) {
            //create an intent to have the default video record take a video.
            Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
            if (takeVideoIntent.resolveActivity(getActivity().getPackageManager()) != null) {
                startActivityForResult(takeVideoIntent, MainActivity.REQUEST_VIDEO_CAPTURE);
            }
        }
    });

    return myView;
}
 
Example 39
Project: AudioVideo   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);
	
	mVideoView = (VideoView)findViewById(R.id.videoView1);
	mVideoView.setMediaController(new MediaController(this));
	
	//setup the button take a video.
	Button btn1 = (Button)findViewById(R.id.button1);
       btn1.setOnClickListener( new View.OnClickListener(){
		@Override
		public void onClick(View v) {
			//create an intent to have the default video record take a video.
		    Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
		    if (takeVideoIntent.resolveActivity(getPackageManager()) != null) {
		        startActivityForResult(takeVideoIntent, REQUEST_VIDEO_CAPTURE);
		    }

		}
       });
	
}
 
Example 40
Project: AudioVideo   File: videoPlay.java   View source code 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    //Get the ViewView 
    vv = (VideoView) this.findViewById( R.id.videoView);
    //add media controls to it.
    vv.setMediaController(new MediaController(this));
    //Setup where the file to play is
    
    //on the SDcard in the root directory.  Not you need permissions to read the external storage.
    //Uri videoUri = Uri.parse(Environment.getExternalStorageDirectory().getPath() + "/the-empire.3gp");
    //Log.v("path",Environment.getExternalStorageDirectory().getPath() );
    
    //via the web.  Note you need Internet permissions.
    Uri videoUri = Uri.parse("http://www.cs.uwyo.edu/~seker/courses/4730/example/the-empire.3gp");
    vv.setVideoURI(videoUri);
    //play the video
    vv.start();

}