Java Code Examples for android.widget.VideoView#start()
The following examples show how to use
android.widget.VideoView#start() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VideoActivity.java From Small with Apache License 2.0 | 7 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_video); getSupportActionBar().setDisplayHomeAsUpEnabled(true); VideoView videoView = (VideoView) findViewById(R.id.video_view); final String uri = "android.resource://" + getPackageName() + "/" + R.raw.fix_429; videoView.setVideoURI(Uri.parse(uri)); // Loop videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { mp.setLooping(true); } }); // Play videoView.start(); }
Example 2
Source File: FormEntryActivity.java From commcare-android with Apache License 2.0 | 6 votes |
private void restoreInlineVideoState() { if (indexOfWidgetWithVideoPlaying != -1) { QuestionWidget widgetWithVideoToResume = uiController.questionsView.getWidgets().get(indexOfWidgetWithVideoPlaying); VideoView inlineVideo = widgetWithVideoToResume.findViewById(MediaLayout.INLINE_VIDEO_PANE_ID); if (inlineVideo != null) { inlineVideo.seekTo(positionOfVideoProgress); inlineVideo.start(); } else { Logger.log(LogTypes.SOFT_ASSERT, "No inline video was found at the question widget index for which a " + "video had been playing before the activity was paused"); } // Reset values now that we have restored indexOfWidgetWithVideoPlaying = -1; positionOfVideoProgress = -1; } }
Example 3
Source File: MainActivity.java From example with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); videoView = (VideoView) findViewById(R.id.videoview); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) videoView.getLayoutParams(); params.width = metrics.widthPixels; params.height = metrics.heightPixels; videoView.setLayoutParams(params); videoView.setVideoURI( Uri.parse("android.resource://" + getPackageName() + "/raw/" + R.raw.momentss)); videoView.start(); // looping videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(MediaPlayer mediaPlayer) { mediaPlayer.setLooping(true); } }); }
Example 4
Source File: VideoActivity.java From VideoCompressor with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_video); vvVideo= (VideoView) findViewById(R.id.vvVideo); geturl=getIntent().getStringExtra("vvVideo"); vvVideo.setVideoPath(geturl); vvVideo.start(); }
Example 5
Source File: VideoCameraActivity.java From Wrox-ProfessionalAndroid-4E with Apache License 2.0 | 5 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == RECORD_VIDEO) { VideoView videoView = findViewById(R.id.videoView); videoView.setVideoURI(data.getData()); videoView.start(); } }
Example 6
Source File: VideocastActivity.java From AnotherRSS with The Unlicense | 5 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_videoweb); VideoView videoView = (VideoView) findViewById(R.id.videoView); WebView webView = (WebView) findViewById(R.id.webView); progressBar = (ProgressBar) findViewById(R.id.progressBar); Intent intent = getIntent(); Uri uri = intent.getData(); if (uri != null) { String url = uri.toString(); if (url.endsWith(".mp4")) { webView.setVisibility(View.GONE); progressBar.setVisibility(View.GONE); videoView.setVisibility(View.VISIBLE); videoView.setMediaController(AnotherRSS.mediaController); videoView.setVideoURI(uri); videoView.requestFocus(); videoView.start(); } else { webView.setVisibility(View.VISIBLE); progressBar.setVisibility(View.VISIBLE); videoView.setVisibility(View.GONE); webView.setWebViewClient(new MyWebClient()); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setLoadWithOverviewMode(true); webView.getSettings().setUseWideViewPort(true); webView.loadUrl(url); } } }
Example 7
Source File: VideoPlayActivity.java From VideoRecord with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_video_play); libPlayVideo_tv_title = (TextView) findViewById(R.id.libPlayVideo_tv_title); libPlayVideo_tv_title.setText("视频播放"); videoView = (VideoView) findViewById(R.id.libPlayVideo_videoView); videoView.setOnErrorListener(new MediaPlayer.OnErrorListener() { @Override public boolean onError(MediaPlayer mp, int what, int extra) { if (isFirst) { isFirst = false; Toast.makeText(VideoPlayActivity.this, "播放该视频异常", Toast.LENGTH_SHORT).show(); } return true; } }); String mVideoPath = getIntent().getStringExtra(VedioRecordActivity.kVideoSavePath); File file = new File(mVideoPath); if (file.exists()) { videoView.setVideoPath(file.getAbsolutePath()); videoView.start(); setLoop(file.getAbsolutePath()); } else { Log.e("tag","not found video " + mVideoPath); } }
Example 8
Source File: MainActivity.java From Android-Basics-Codes with Artistic License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); VideoView vv = (VideoView) findViewById(R.id.vv); vv.setVideoPath("sdcard/2.3gp"); vv.start(); }
Example 9
Source File: HomeSplashFragment.java From Android with MIT License | 4 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.home_splash_screen, container, false); mContext = this.getActivity(); Button login_fragment = view.findViewById(R.id.login_fragment); Button signup_fragment = view.findViewById(R.id.signup_fragment); VideoView videoview = view.findViewById(R.id.videoview); mPager = view.findViewById(R.id.pager); indicator = view.findViewById(R.id.indicator); ImageView background_image_home_fragment = (ImageView) view.findViewById(R.id.background_image_home_fragment); login_fragment.setOnClickListener(this); signup_fragment.setOnClickListener(this); if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) { videoview.setVisibility(View.GONE); background_image_home_fragment.setVisibility(View.VISIBLE); }else { Uri uri = Uri.parse("android.resource://" + mContext.getPackageName() + "/" + R.raw.story); videoview.setVideoURI(uri); videoview.start(); final int duration = 4000; final int colorFrom = Color.parseColor("#10000000"); final int colorTo = Color.parseColor("#b8000000"); ColorDrawable[] color = {new ColorDrawable(colorFrom), new ColorDrawable(colorTo)}; TransitionDrawable transition = new TransitionDrawable(color); videoview.setBackground(transition); transition.startTransition(duration); //Video Loop videoview.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { mp.setVideoScalingMode(MediaPlayer.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING); mp.setLooping(true); mp.setVolume(0f, 0f); } }); } init(); return view; }
Example 10
Source File: AnimationDialogLayout.java From weMessage with GNU Affero General Public License v3.0 | 4 votes |
public void startAnimation(){ VideoView videoView = findViewById(R.id.animationDialogVideoView); videoView.seekTo(0); videoView.start(); }
Example 11
Source File: WatchVideoActivity.java From o2oa with GNU Affero General Public License v3.0 | 3 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_watch_video); mVv_video = (VideoView) findViewById(R.id.vv_video); String videoPath = getIntent().getStringExtra("video_path"); mVv_video.setVideoPath(videoPath); mVv_video.start(); }