Java 类android.widget.VideoView 实例源码

项目:NotifyTools    文件:MainActivity.java   
@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();
                }
            });


        }
项目:AndroidBookTest    文件:MainActivity.java   
@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
    }
}
项目:PLDroidShortVideo    文件:VideoTrimActivity.java   
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();
}
项目:apps_small    文件:MainActivity.java   
@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();

}
项目:mpeg-encoder    文件:MainActivity.java   
/** {@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());
}
项目:AndroidFFmpegCompress    文件:VideoPlayerActivity.java   
@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();
    }
}
项目:LifeSaver    文件:Main4Activity.java   
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();


    }
项目:LifeSaver    文件:Main3Activity.java   
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();





    }
项目:boohee_v5.6    文件:MentionPreviewActivity$$ViewInjector.java   
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'");
}
项目:YCGallery    文件:VideoPlayerActivity.java   
@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));
}
项目:EsperantoRadio    文件:LocalPlayerActivity.java   
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();
        }
    });
}
项目:minVideo    文件:VideoActivity.java   
@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();
}
项目:RLibrary    文件:VideoPlayActivity.java   
@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);
}
项目:Touch-to-record-Camera    文件:PreviewActivity.java   
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);
    }
}
项目:ChatUp    文件:ChatFragment.java   
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);
}
项目:CastVideos-android    文件:LocalPlayerActivity.java   
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();
        }
    });
}
项目:android-lite    文件:VideoActivity.java   
@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);
}
项目:Marv    文件:VideoFull.java   
@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();
}
项目:Cirrus    文件:PreviewMediaFragment.java   
/**
 * {@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;
}
项目:TDT-Spain    文件:PlayerActivity.java   
@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);
    }


}
项目:mytarget-android    文件:InstreamAdActivity.java   
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();
}
项目:AndroidFFmpegCMDTool    文件:VideoProcessActivity.java   
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();
}
项目:cast-videos-android    文件:LocalPlayerActivity.java   
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();
        }
    });
}
项目:cast-videos-android    文件:LocalPlayerActivity.java   
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();
        }
    });
}
项目:ScrollGallery-android    文件:VideoPlayerActivity.java   
@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));
}
项目:bullseye    文件:PreviewActivity.java   
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);
    }
}
项目:bullseye    文件:PreviewFragment.java   
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);
    }
}
项目:EDSApp    文件:VideoActivity.java   
@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();
}
项目:youkes_vr    文件:SideBySideVideoPlayActivity.java   
@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();
}
项目:faims-android    文件:FileGalleryPreviewDialog.java   
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);
}
项目:galactic-tavern-android    文件:VideoPlayerActivity.java   
@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));
}
项目:DexShiftingView    文件:ContentFragment.java   
@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;
    }
}
项目:DexShiftingView    文件:ContentPagerFragment.java   
@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;
    }
}
项目:alternate-java-bridge-library    文件:VideoPlayer.java   
/**
 * 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 = "";
}
项目:videoComparator    文件:VideoComparatorActivity.java   
/**
 * 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;
}
项目:videoComparator    文件:VideoComparatorActivity.java   
/**
 * (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();
}
项目:AudioVideo    文件:MainFragment.java   
@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;
}
项目:AudioVideo    文件:MainActivity.java   
@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);
            }

        }
       });

}
项目:AudioVideo    文件:videoPlay.java   
@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();

}
项目:codelab-chromecast    文件:LocalPlayerActivity.java   
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);
    mEndText = (TextView) findViewById(R.id.endText);
    mSeekbar = (SeekBar) findViewById(R.id.seekBar1);
    // mVolBar = (SeekBar) findViewById(R.id.seekBar2);
    mPlayPause = (ImageView) findViewById(R.id.imageView2);
    mLoading = (ProgressBar) findViewById(R.id.progressBar1);
    // mVolumeMute = (ImageView) findViewById(R.id.imageView2);
    mControlers = findViewById(R.id.controllers);
    mContainer = findViewById(R.id.container);
    mCoverArt = (ImageView) findViewById(R.id.coverArtView);
}