当前位置: 首页>>代码示例>>Java>>正文


Java VideoView类代码示例

本文整理汇总了Java中android.widget.VideoView的典型用法代码示例。如果您正苦于以下问题:Java VideoView类的具体用法?Java VideoView怎么用?Java VideoView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


VideoView类属于android.widget包,在下文中一共展示了VideoView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.widget.VideoView; //导入依赖的package包/类
@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();

}
 
开发者ID:alaskalinuxuser,项目名称:apps_small,代码行数:26,代码来源:MainActivity.java

示例2: onCreate

import android.widget.VideoView; //导入依赖的package包/类
@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();
                }
            });


        }
 
开发者ID:yippeesoft,项目名称:NotifyTools,代码行数:26,代码来源:MainActivity.java

示例3: onCreate

import android.widget.VideoView; //导入依赖的package包/类
@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
    }
}
 
开发者ID:Qinlong275,项目名称:AndroidBookTest,代码行数:20,代码来源:MainActivity.java

示例4: init

import android.widget.VideoView; //导入依赖的package包/类
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();
}
 
开发者ID:pili-engineering,项目名称:PLDroidShortVideo,代码行数:26,代码来源:VideoTrimActivity.java

示例5: onCreate

import android.widget.VideoView; //导入依赖的package包/类
/** {@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());
}
 
开发者ID:Nik-Gleb,项目名称:mpeg-encoder,代码行数:21,代码来源:MainActivity.java

示例6: onCreate

import android.widget.VideoView; //导入依赖的package包/类
@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();
    }
}
 
开发者ID:mChenys,项目名称:AndroidFFmpegCompress,代码行数:22,代码来源:VideoPlayerActivity.java

示例7: go

import android.widget.VideoView; //导入依赖的package包/类
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();


    }
 
开发者ID:iamjaspreetsingh,项目名称:LifeSaver,代码行数:19,代码来源:Main4Activity.java

示例8: go

import android.widget.VideoView; //导入依赖的package包/类
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();





    }
 
开发者ID:iamjaspreetsingh,项目名称:LifeSaver,代码行数:23,代码来源:Main3Activity.java

示例9: initPlayer

import android.widget.VideoView; //导入依赖的package包/类
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);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:14,代码来源:VideoPlayerManager.java

示例10: inject

import android.widget.VideoView; //导入依赖的package包/类
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'");
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:23,代码来源:MentionPreviewActivity$$ViewInjector.java

示例11: onCreate

import android.widget.VideoView; //导入依赖的package包/类
@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));
}
 
开发者ID:yangchong211,项目名称:YCGallery,代码行数:22,代码来源:VideoPlayerActivity.java

示例12: loadViews

import android.widget.VideoView; //导入依赖的package包/类
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();
        }
    });
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:25,代码来源:LocalPlayerActivity.java

示例13: onCreate

import android.widget.VideoView; //导入依赖的package包/类
@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();
}
 
开发者ID:tryBetter,项目名称:minVideo,代码行数:19,代码来源:VideoActivity.java

示例14: onCreate

import android.widget.VideoView; //导入依赖的package包/类
@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);
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:26,代码来源:VideoPlayActivity.java

示例15: init

import android.widget.VideoView; //导入依赖的package包/类
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);
    }
}
 
开发者ID:aynurkacak,项目名称:Touch-to-record-Camera,代码行数:20,代码来源:PreviewActivity.java


注:本文中的android.widget.VideoView类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。