Java Examples for android.widget.VideoView
The following java examples will help you to understand the usage of android.widget.VideoView. These source code samples are taken from different open source projects.
Example 1
| Project: android-app-study-master File: VideoPlayerActivity.java View source code |
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Window win = getWindow();
win.requestFeature(Window.FEATURE_NO_TITLE);
win.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
VideoView video = (VideoView) findViewById(R.id.videoView1);
File sdcard = new File(Environment.getExternalStorageDirectory(), "Heartbeat-applegirl.mp4");
video.setVideoPath(sdcard.toString());
video.start();
}Example 2
| Project: android-linkit-buyer-master File: FragmentIntro.java View source code |
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
((MainActivity) getActivity()).currentFragmentName = "Intro";
View rootView = inflater.inflate(R.layout.fragment_intro, container, false);
VideoView videoView = (VideoView) rootView.findViewById(R.id.videoViewIntro);
String UrlPath = "android.resource://" + getActivity().getPackageName() + "/" + R.raw.introvideo_shopper_square;
videoView.setVideoURI(Uri.parse(UrlPath));
videoView.start();
return rootView;
}Example 3
| Project: AngryKings-master File: IntroActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_intro);
VideoView videoView = (VideoView) findViewById(R.id.videoView1);
String uri = "android.resource://" + getPackageName() + "/" + R.raw.intro;
videoView.setVideoURI(Uri.parse(uri));
videoView.start();
videoView.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer arg0) {
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent);
}
});
}Example 4
| Project: AppJone-master File: FullVideoPlayActivity.java View source code |
@SuppressLint("WrongViewCast")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_full_video_play);
final View controlsView = findViewById(R.id.fullscreen_content_controls);
videoView = (VideoView) findViewById(R.id.fullscreen_content);
// Set up an instance of SystemUiHider to control the system UI for
// this activity.
mSystemUiHider = SystemUiHider.getInstance(this, videoView, HIDER_FLAGS);
mSystemUiHider.setup();
mSystemUiHider.setOnVisibilityChangeListener(new SystemUiHider.OnVisibilityChangeListener() {
// Cached values.
int mControlsHeight;
int mShortAnimTime;
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
public void onVisibilityChange(boolean visible) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
// screen.
if (mControlsHeight == 0) {
mControlsHeight = controlsView.getHeight();
}
if (mShortAnimTime == 0) {
mShortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);
}
controlsView.animate().translationY(visible ? 0 : mControlsHeight).setDuration(mShortAnimTime);
} else {
// If the ViewPropertyAnimator APIs aren't
// available, simply show or hide the in-layout UI
// controls.
controlsView.setVisibility(visible ? View.VISIBLE : View.GONE);
}
if (visible && AUTO_HIDE) {
// Schedule a hide().
delayedHide(AUTO_HIDE_DELAY_MILLIS);
}
}
});
// Set up the user interaction to manually show or hide the system UI.
videoView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (TOGGLE_ON_CLICK) {
mSystemUiHider.toggle();
} else {
mSystemUiHider.show();
}
}
});
// Upon interacting with UI controls, delay any scheduled hide()
// operations to prevent the jarring behavior of controls going away
// while interacting with the UI.
findViewById(R.id.dummy_button).setOnTouchListener(mDelayHideTouchListener);
MediaController mController = new MediaController(this);
//设置一个控制�
videoView.setMediaController(mController);
Bundle bundle = getIntent().getExtras();
if (bundle != null) {
String videoPath = bundle.getString(Constants.IMAGE_PATH_KEY);
if (videoPath != null) {
videoView.setVideoPath(videoPath);
videoView.start();
}
}
}Example 5
| Project: cw-andtutorials-master File: HelpCast.java View source code |
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
setContentView(R.layout.helpcast);
File clip = new File(Environment.getExternalStorageDirectory(), "helpcast.mp4");
if (clip.exists()) {
video = (VideoView) findViewById(R.id.video);
video.setVideoPath(clip.getAbsolutePath());
ctlr = new MediaController(this);
ctlr.setMediaPlayer(video);
video.setMediaController(ctlr);
video.requestFocus();
video.start();
}
}Example 6
| Project: Glass-Photo-Gallery-master File: VideoPlayerActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String videoUrl = getIntent().getExtras().getString("videoUrl");
if (videoUrl != null) {
VideoView videoView = new VideoView(this);
videoView.setMediaController(new MediaController(this));
videoView.setVideoURI(Uri.parse(videoUrl));
videoView.requestFocus();
videoView.start();
setContentView(videoView);
} else {
return;
}
}Example 7
| Project: gyz-master File: PlayVoiceActivity.java View source code |
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.slaveinfo_voice);
path = getIntent().getStringExtra("url");
Uri uri = Uri.parse(Constants.getVoiceUrl() + path);
//Uri uri = Uri.parse("file:///sdcard/music/dufuhenmang.3gp");
VideoView videoView = (VideoView) this.findViewById(R.id.videoView);
videoView.setMediaController(new MediaController(this));
videoView.setVideoURI(uri);
videoView.start();
videoView.requestFocus();
}Example 8
| Project: mobmonkey-android-master File: VideoPlayerScreen.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.video_player_screen);
vvVideoPlayer = (VideoView) findViewById(R.id.vvvideoplayer);
vvVideoPlayer.setVideoURI(Uri.parse(getIntent().getStringExtra(MMSDKConstants.JSON_KEY_MEDIA_URL)));
vvVideoPlayer.setMediaController(new MediaController(VideoPlayerScreen.this));
vvVideoPlayer.start();
}Example 9
| Project: uw-android-master File: SimpleVideoPlayerActivity.java View source code |
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_simple_video_player);
VideoView videoView = (VideoView) findViewById(R.id.simple_video_player_video_view);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
// Uri uri= Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.test_video);
// videoView.setMediaController(mediaController);
// videoView.setVideoURI(uri);
// videoView.requestFocus();
//
// videoView.start();
}Example 10
| Project: android_explore-master File: Activity01.java View source code |
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
/* ´´½¨VideoView¶ÔÏó */
final VideoView videoView = (VideoView) findViewById(R.id.VideoView01);
/* ²Ù×÷²¥·ÅµÄÈý¸ö°´Å¥ */
Button PauseButton = (Button) this.findViewById(R.id.PauseButton);
Button LoadButton = (Button) this.findViewById(R.id.LoadButton);
Button PlayButton = (Button) this.findViewById(R.id.PlayButton);
/* ×°ÔØ°´Å¥Ê¼þ */
LoadButton.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
/* ÉèÖ÷¾¶ */
videoView.setVideoPath("/sdcard/test.mp4");
/* ÉèÖÃģʽ-²¥·Å½ø¶ÈÌõ */
videoView.setMediaController(new MediaController(Activity01.this));
videoView.requestFocus();
}
});
/* ²¥·Å°´Å¥Ê¼þ */
PlayButton.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
/* ¿ªÊ¼²¥·Å */
videoView.start();
}
});
/* ÔÝÍ£°´Å¥ */
PauseButton.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
/* ÔÝÍ£ */
videoView.pause();
}
});
}Example 11
| Project: clipboard-actions-master File: MuseC.java View source code |
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.muse, null);
screen = (VideoView) v.findViewById(R.id.screen);
worded = (TextView) v.findViewById(R.id.worded);
title = (TextView) v.findViewById(R.id.title);
title.setText(R.string.intro3Title);
worded.setText(R.string.intro3Text);
Uri uri = Uri.parse("android.resource://" + getActivity().getPackageName() + "/" + R.raw.intro3);
screen.setVideoURI(uri);
screen.requestFocus();
screen.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer pee) {
pee.setLooping(true);
}
});
screen.start();
return v;
}Example 12
| Project: coursera-android-master File: AudioVideoVideoPlayActivity.java View source code |
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Get a reference to the VideoView
mVideoView = (VideoView) findViewById(R.id.videoViewer);
// Add a Media controller to allow forward/reverse/pause/resume
final MediaController mMediaController = new MediaController(AudioVideoVideoPlayActivity.this, true);
mMediaController.setEnabled(false);
mVideoView.setMediaController(mMediaController);
mVideoView.setVideoURI(Uri.parse("android.resource://course.examples.AudioVideo.VideoPlay/raw/moon"));
// Add an OnPreparedListener to enable the MediaController once the video is ready
mVideoView.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mMediaController.setEnabled(true);
}
});
}Example 13
| Project: FFmpegRecorder-master File: PlaybackActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_playback);
TextView tvVideoPath = (TextView) findViewById(R.id.tv_video_path);
mVvPlayback = (VideoView) findViewById(R.id.vv_playback);
String path = getIntent().getStringExtra(INTENT_NAME_VIDEO_PATH);
if (path == null) {
finish();
}
tvVideoPath.setText(path);
mVvPlayback.setVideoPath(path);
mVvPlayback.setKeepScreenOn(true);
mVvPlayback.setMediaController(new MediaController(this));
mVvPlayback.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
}
});
mVvPlayback.start();
}Example 14
| Project: kuliah_mobile-master File: AudioVideoVideoPlayActivity.java View source code |
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Get a reference to the VideoView
mVideoView = (VideoView) findViewById(R.id.videoViewer);
// Add a Media controller to allow forward/reverse/pause/resume
final MediaController mMediaController = new MediaController(AudioVideoVideoPlayActivity.this, true);
mMediaController.setEnabled(false);
mVideoView.setMediaController(mMediaController);
mVideoView.setVideoURI(Uri.parse("android.resource://course.examples.AudioVideo.VideoPlay/raw/moon"));
// Add an OnPreparedListener to enable the MediaController once the video is ready
mVideoView.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mMediaController.setEnabled(true);
}
});
}Example 15
| Project: mobile-ecommerce-android-education-master File: VideoDemoActivity.java View source code |
/** Called when the activity is first created. */
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.c10_media_video_demo_layout);
VideoView videoView = (VideoView) this.findViewById(R.id.videoView);
MediaController mc = new MediaController(this);
videoView.setMediaController(mc);
// videoView.setVideoURI(Uri.parse(
// "http://www.androidbook.com/akc/filestorage/android/documentfiles/3389/movie.mp4"));
// videoView.setVideoPath(
// Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES)
// +
// "/movie.mp4");
videoView.setVideoURI(Uri.parse("file://" + Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES) + "/GANGNAM_STYLE_MV.mp4"));
videoView.requestFocus();
videoView.start();
}Example 16
| Project: Small-master File: VideoActivity.java View source code |
@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 17
| Project: SmarterStreaming-master File: RecorderPlayback.java View source code |
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recorder_playback);
Intent intent = getIntent();
recorderFilePath = intent.getStringExtra("RecorderFilePath");
filePathTextView = (TextView) findViewById(R.id.textViewRecoderPlaybackFilePath);
if (recorderFilePath != null) {
filePathTextView.setText(recorderFilePath);
} else {
Log.i(Tag, "recorderFilePath is null");
}
playVideoView = (VideoView) findViewById(R.id.VideoViewRecoderPlayback);
if (recorderFilePath != null && !recorderFilePath.isEmpty()) {
playVideoView.setVideoPath(recorderFilePath);
playVideoView.setMediaController(new MediaController(this));
playVideoView.requestFocus();
playVideoView.start();
}
}Example 18
| Project: WS171-development-master File: VideoViewDemo.java View source code |
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.videoview);
mVideoView = (VideoView) findViewById(R.id.surface_view);
if (path == "") {
// Tell the user to provide a media file URL/path.
Toast.makeText(VideoViewDemo.this, "Please edit VideoViewDemo Activity, and set path" + " variable to your media file URL/path", Toast.LENGTH_LONG).show();
} else {
/*
* Alternatively,for streaming media you can use
* mVideoView.setVideoURI(Uri.parse(URLstring));
*/
mVideoView.setVideoPath(path);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
}
}Example 19
| Project: crtaci-master File: PlayerActivity.java View source code |
public void defaultPlayer(String url) {
setContentView(R.layout.player);
final VideoView videoView = (VideoView) findViewById(R.id.video_view);
final ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress_bar);
progressBar.setVisibility(View.VISIBLE);
videoView.setOnPreparedListener(new android.media.MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(android.media.MediaPlayer mp) {
progressBar.setVisibility(View.INVISIBLE);
videoView.start();
}
});
videoView.setOnErrorListener(new android.media.MediaPlayer.OnErrorListener() {
@Override
public boolean onError(android.media.MediaPlayer mp, int what, int extra) {
Log.d(TAG, "onError");
if (retry >= 2) {
video = null;
switch(cartoon.service) {
case "youtube":
playYouTube();
break;
case "dailymotion":
playDailyMotion();
break;
case "vimeo":
playVimeo();
break;
}
} else {
Log.d(TAG, "retry " + String.valueOf(retry));
new ExtractTask().execute(cartoon.service, cartoon.id);
}
return true;
}
});
videoView.setOnCompletionListener(new android.media.MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(android.media.MediaPlayer mediaPlayer) {
onBackPressed();
}
});
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
mediaController.setMediaPlayer(videoView);
videoView.setKeepScreenOn(true);
videoView.setMediaController(mediaController);
videoView.setVideoURI(Uri.parse(url));
videoView.requestFocus();
}Example 20
| Project: cnBetaReader-master File: BaseWebChromeClient.java View source code |
@Override
public void onShowCustomView(View view, CustomViewCallback callback) {
if (view instanceof FrameLayout) {
// A video wants to be shown
FrameLayout frameLayout = (FrameLayout) view;
View focusedChild = frameLayout.getFocusedChild();
// Save video related variables
mIsVideoFullscreen = true;
mVideoViewFrameLayout = frameLayout;
mVideoViewCallback = callback;
// Hide the non-video view, add the video view, and show it
mNonFullscreenVideoLayout.setVisibility(View.INVISIBLE);
mFullscreenVideoLayout.addView(mVideoViewFrameLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
mFullscreenVideoLayout.setVisibility(View.VISIBLE);
if (focusedChild instanceof android.widget.VideoView) {
// android.widget.VideoView (typically API level <11)
VideoView videoView = (VideoView) focusedChild;
// Handle all the required events
videoView.setOnPreparedListener(this);
videoView.setOnCompletionListener(this);
videoView.setOnErrorListener(this);
} else {
// doesn't work fullscreen when loading the javascript below
if (mWebView != null && mWebView.getSettings().getJavaScriptEnabled() && focusedChild instanceof SurfaceView) {
// Run javascript code that detects the video end and
// notifies the Javascript interface
String js = "javascript:";
js += "var _ytrp_html5_video_last;";
js += "var _ytrp_html5_video = document.getElementsByTagName('video')[0];";
js += "if (_ytrp_html5_video != undefined && _ytrp_html5_video != _ytrp_html5_video_last) {";
{
js += "_ytrp_html5_video_last = _ytrp_html5_video;";
js += "function _ytrp_html5_video_ended() {";
{
js += "_VideoEnabledWebView.notifyVideoEnd();";
}
js += "}";
js += "_ytrp_html5_video.addEventListener('ended', _ytrp_html5_video_ended);";
}
js += "}";
injectJS(mWebView, js);
}
}
// Notify full-screen change
if (mOutCallback != null) {
mOutCallback.enterFullscreenVideo();
}
}
}Example 21
| Project: andevcon-2014-jl-master File: VideoViewDemo.java View source code |
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.videoview);
mVideoView = (VideoView) findViewById(R.id.surface_view);
/*
* Alternatively, you can use mVideoView.setVideoPath(<path>);
*/
mVideoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.videoviewdemo));
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
}Example 22
| Project: android-apidemos-master File: VideoViewDemo.java View source code |
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.videoview);
mVideoView = (VideoView) findViewById(R.id.surface_view);
if (path == "") {
// Tell the user to provide a media file URL/path.
Toast.makeText(VideoViewDemo.this, "Please edit VideoViewDemo Activity, and set path" + " variable to your media file URL/path", Toast.LENGTH_LONG).show();
} else {
/*
* Alternatively,for streaming media you can use
* mVideoView.setVideoURI(Uri.parse(URLstring));
*/
mVideoView.setVideoPath(path);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
}
}Example 23
| Project: android-maven-plugin-master File: VideoViewDemo.java View source code |
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.videoview);
mVideoView = (VideoView) findViewById(R.id.surface_view);
if (path == "") {
// Tell the user to provide a media file URL/path.
Toast.makeText(VideoViewDemo.this, "Please edit VideoViewDemo Activity, and set path" + " variable to your media file URL/path", Toast.LENGTH_LONG).show();
} else {
/*
* Alternatively,for streaming media you can use
* mVideoView.setVideoURI(Uri.parse(URLstring));
*/
mVideoView.setVideoPath(path);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
}
}Example 24
| Project: Android-SDK-Samples-master File: VideoViewDemo.java View source code |
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.videoview);
mVideoView = (VideoView) findViewById(R.id.surface_view);
if (path == "") {
// Tell the user to provide a media file URL/path.
Toast.makeText(VideoViewDemo.this, "Please edit VideoViewDemo Activity, and set path" + " variable to your media file URL/path", Toast.LENGTH_LONG).show();
} else {
/*
* Alternatively,for streaming media you can use
* mVideoView.setVideoURI(Uri.parse(URLstring));
*/
mVideoView.setVideoPath(path);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
}
}Example 25
| Project: AndroidSDK-RecipeBook-master File: Recipe067.java View source code |
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mVideoView = (VideoView) findViewById(R.id.video_view);
// MediaControllerを作��
mMediaController = new MediaController(this);
// MediaControllerセット
mVideoView.setMediaController(mMediaController);
// VideoViewã?§å‹•画をå†?生ã?™ã‚‹æº–å‚™ã?Œã?§ã??ã?Ÿæ™‚ã?«
// 呼�出�れるリスナー
mVideoView.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
// 3,4秒�MediaController�消��ゃ���
// 常ã?«è¡¨ç¤ºã?•ã?›ã?¦ã?Šã??ã?Ÿã?„ã‚“ã? ã?‘ã?©
// showメソッドã?ŒæœŸå¾…通りã?«å‹•作ã?—ã?¦ã??れã?ªã?„
// durationã?¯æ£ã?—ã??å?–å¾—ã?§ã??ã?¦ã‚‹ã€‚
int duration = mVideoView.getDuration();
mMediaController.show(duration);
// リファレンスを信��0���もダメ
// mMediaController.show(0);
// ã?¾ã??æ°—ã?«ã?›ã?šå†?生スタートï¼?
mVideoView.start();
}
});
}Example 26
| Project: apidemo-master File: VideoViewDemo.java View source code |
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.videoview);
mVideoView = (VideoView) findViewById(R.id.surface_view);
if (path == "") {
// Tell the user to provide a media file URL/path.
Toast.makeText(VideoViewDemo.this, "Please edit VideoViewDemo Activity, and set path" + " variable to your media file URL/path", Toast.LENGTH_LONG).show();
} else {
/*
* Alternatively,for streaming media you can use
* mVideoView.setVideoURI(Uri.parse(URLstring));
*/
mVideoView.setVideoPath(path);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
}
}Example 27
| Project: ApiDemos-master File: VideoViewDemo.java View source code |
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.videoview);
mVideoView = (VideoView) findViewById(R.id.surface_view);
/*
* Alternatively, you can use mVideoView.setVideoPath(<path>);
*/
mVideoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.videoviewdemo));
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
}Example 28
| Project: ApkLauncher-master File: VideoViewDemo.java View source code |
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.videoview);
mVideoView = (VideoView) findViewById(R.id.surface_view);
/*
* Alternatively, you can use mVideoView.setVideoPath(<path>);
*/
mVideoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.videoviewdemo));
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
}Example 29
| Project: ApkLauncher_legacy-master File: VideoViewDemo.java View source code |
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.videoview);
mVideoView = (VideoView) findViewById(R.id.surface_view);
/*
* Alternatively, you can use mVideoView.setVideoPath(<path>);
*/
mVideoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.videoviewdemo));
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
}Example 30
| Project: aurora-imui-master File: VideoActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video);
String videoPath = getIntent().getStringExtra(VIDEO_PATH);
mVideoView = (VideoView) findViewById(R.id.videoview_video);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(mVideoView);
mVideoView.setMediaController(mediaController);
mVideoView.setVideoPath(videoPath);
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mVideoView.requestLayout();
if (mSavedCurrentPosition != 0) {
mVideoView.seekTo(mSavedCurrentPosition);
mSavedCurrentPosition = 0;
} else {
play();
}
}
});
mVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
mVideoView.setKeepScreenOn(false);
}
});
}Example 31
| Project: BrillaMXAndroid-master File: Emp3.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_emp3);
ctx = this;
Toolbar toolbar = (Toolbar) findViewById(R.id.app_bar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
/**
* Facebook like
*/
uiHelper = new UiLifecycleHelper(this, mStatusCallback);
like_view = (LikeView) findViewById(R.id.likeEmp1);
like_view.setObjectId(like_url);
like_view.setLikeViewStyle(LikeView.Style.STANDARD);
like_view.setAuxiliaryViewPosition(LikeView.AuxiliaryViewPosition.INLINE);
like_view.setHorizontalAlignment(LikeView.HorizontalAlignment.LEFT);
/**
* Video
*/
String uriPath = "android.resource://mx.ambmultimedia.brillamexico/raw/bmx_emp3";
Uri uri = Uri.parse(uriPath);
final ImageView videoPreview = (ImageView) findViewById(R.id.videoPreview);
video = (VideoView) findViewById(R.id.videoView);
video.setVideoURI(uri);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(video);
video.setMediaController(mediaController);
final FloatingActionButton playVideo = (FloatingActionButton) findViewById(R.id.playVideo);
playVideo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
playVideo.setVisibility(View.INVISIBLE);
videoPreview.setVisibility(View.INVISIBLE);
video.start();
}
});
float videoWidth = (float) video.getWidth();
float videoHeight = videoWidth * 0.5625f;
video.layout(0, 0, (int) videoWidth, (int) videoHeight);
video.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
public void onPrepared(MediaPlayer arg) {
video.start();
video.pause();
}
});
video.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer vmp) {
playVideo.setVisibility(View.VISIBLE);
videoPreview.setVisibility(View.VISIBLE);
}
});
video.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
video.pause();
}
});
/**
* Compartir emprendedor
*/
final String title = "FRANCISCO X. VILLASEÑOR";
final String link = "http://www.brillamexico.org/francisco-x-villasenor/";
FloatingActionButton share = (FloatingActionButton) findViewById(R.id.shareContent);
share.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, title);
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, link);
startActivity(Intent.createChooser(sharingIntent, "Compartir"));
}
});
}Example 32
| Project: cw-advandroid-master File: VideoDemo.java View source code |
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
setContentView(R.layout.main);
File clip = new File(Environment.getExternalStorageDirectory(), "test.mp4");
if (clip.exists()) {
video = (VideoView) findViewById(R.id.video);
video.setVideoPath(clip.getAbsolutePath());
ctlr = new MediaController(this);
ctlr.setMediaPlayer(video);
video.setMediaController(ctlr);
video.requestFocus();
video.start();
}
}Example 33
| Project: cw-omnibus-master File: VideoPlayerActivity.java View source code |
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.player);
video = (VideoView) findViewById(R.id.player);
ctlr = new MediaController(this);
ctlr.setMediaPlayer(video);
video.setMediaController(ctlr);
fab = findViewById(R.id.pip);
fab.setOnClickListener(this);
current = getIntent();
play();
}Example 34
| Project: cwac-cam2-master File: VideoPlayerActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
vv = new VideoView(this, null);
setContentView(vv, new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT, Gravity.CENTER));
vv.setVideoURI(getIntent().getData());
vv.setOnCompletionListener(this);
vv.start();
if (savedInstanceState != null) {
vv.seekTo(savedInstanceState.getInt(STATE_OFFSET, 0));
}
}Example 35
| Project: development_apps_spareparts-master File: SamplePluginStub.java View source code |
public View getFullScreenView(int npp, Context context) {
/* TODO make this aware of the plugin instance and get the video file
* from the plugin.
*/
FrameLayout layout = new FrameLayout(context);
LayoutParams fp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
layout.setLayoutParams(fp);
VideoView video = new VideoView(context);
LayoutParams vp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
layout.setLayoutParams(vp);
GLSurfaceView gl = new GLSurfaceView(context);
LayoutParams gp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
layout.setLayoutParams(gp);
layout.addView(video);
layout.addView(gl);
// We want an 8888 pixel format because that's required for a translucent
// window. And we want a depth buffer.
gl.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
// Tell the cube renderer that we want to render a translucent version
// of the cube:
gl.setRenderer(new CubeRenderer(true));
// Use a surface format with an Alpha channel:
gl.getHolder().setFormat(PixelFormat.TRANSLUCENT);
gl.setWindowType(WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY);
video.setVideoPath("/sdcard/test_video.3gp");
video.setMediaController(new MediaController(context));
video.requestFocus();
return layout;
}Example 36
| Project: FactoryTest-master File: AgeingActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.ageing_layout);
super.onCreate(savedInstanceState);
videoView = (VideoView) this.findViewById(R.id.videoView);
// MediaController mc = new MediaController(this);
// videoView.setMediaController(mc);
//Uri uri = Uri.parse("/mnt/sdcard2/video.mp4");
//Uri uri = Uri.parse("/mnt/sdcard2/video.mp4");
//videoView.setVideoURI(uri);
videoView.setVideoPath("android.resource://" + getPackageName() + "/" + R.raw.video);
videoView.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
mp.start();
}
});
// videoView.setOnErrorListener(new OnErrorListener() {
//
// @Override
// public boolean onError(MediaPlayer mp, int what, int extra) {
// // TODO Auto-generated method stub
// return true;
// }
// });
videoView.requestFocus();
videoView.start();
// changeImage();
this.getWindow().setBackgroundDrawable(getResources().getDrawable(R.drawable.water_logo));
}Example 37
| Project: felix-on-android-master File: VideoViewDemo.java View source code |
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.videoview);
mVideoView = (VideoView) findViewById(R.id.surface_view);
/*
* Alternatively, you can use mVideoView.setVideoPath(<path>);
*/
mVideoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.videoviewdemo));
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
}Example 38
| Project: GradleCodeLab-master File: VideoViewDemo.java View source code |
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.videoview);
mVideoView = (VideoView) findViewById(R.id.surface_view);
/*
* Alternatively, you can use mVideoView.setVideoPath(<path>);
*/
mVideoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.videoviewdemo));
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
}Example 39
| Project: hippie-master File: SplashScreenActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.activity_splash_land);
//identifiant du vidéo
this.videoView = (VideoView) this.findViewById(R.id.videoView);
//le chemin du vidéo
this.videoView.setVideoURI(Uri.parse("android.resource://" + this.getPackageName() + "/" + R.raw.denree_o_suivant));
//le démarrage du vidéo Logo dans le splash screen
this.videoView.start();
this.handler.postDelayed(this.endSplashScreen, SPLASH_TIME_OUT);
}Example 40
| Project: message-samples-android-master File: VideoViewActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video_view);
ActionBar ab = getSupportActionBar();
if (ab != null) {
ab.setDisplayHomeAsUpEnabled(true);
}
String imageUrl = getIntent().getStringExtra("videoUrl");
Uri uri = Uri.parse(imageUrl);
vidMessageVideo = (VideoView) findViewById(R.id.vidMessageVideo);
vidMessageVideo.setMediaController(new MediaController(this));
vidMessageVideo.setVideoURI(uri);
vidMessageVideo.requestFocus();
vidMessageVideo.start();
}Example 41
| Project: MIT-Mobile-for-Android-master File: MIT150VideoActivity.java View source code |
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.video);
final Context ctx = this;
final Uri video = Uri.parse("android.resource://" + Config.release_project_name + "/raw/hockfield_150");
videoPlayer = (VideoView) findViewById(R.id.videoView);
mediaCtrl = new MediaController(this);
mediaCtrl.setAnchorView(videoPlayer);
videoPlayer.setMediaController(mediaCtrl);
videoPlayer.setVideoURI(video);
videoPlayer.setOnErrorListener(new OnErrorListener() {
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
// #1
int pos = mp.getCurrentPosition();
mp.reset();
try {
mp.setDataSource(ctx, video);
mp.prepare();
mp.start();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
mp.seekTo(pos);
// false causes OnCompletion
return true;
}
});
videoPlayer.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
// needed to avoid Froyo hang bug?
mediaCtrl.setEnabled(false);
finish();
}
});
videoPlayer.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
// also need to wait before starting to avoid hanging bug...
mp.start();
}
});
// maybe needed to avoid hanging? (according to one forum post)
videoPlayer.setFocusable(false);
videoPlayer.setClickable(false);
}Example 42
| Project: mobile-client-master File: VideoPlayer.java View source code |
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
IU.setCustomTitle(this);
setContentView(R.layout.video_player);
Bundle extras = getIntent().getExtras();
String video = extras.getString("nombre_video");
String video_without_mp4 = video.substring(0, video.length() - 3);
// String path="http://www.ted.com/talks/download/video/8584/talk/761";
// String path1="http://commonsware.com/misc/test2.3gp";
//
// Uri uri=Uri.parse(path);
//Calling VideoView
VideoView videoView = (VideoView) findViewById(R.id.VideoView);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
String resource = "http://148.240.229.64/Video/" + video_without_mp4 + "mp4";
mediaController = new MediaController(this);
mediaController.setMediaPlayer(videoView);
// Uri uri = Uri.parse(resource);
// videoView.setVideoURI(uri);
videoView.setVideoPath(resource);
videoView.setMediaController(mediaController);
videoView.start();
videoView.requestFocus();
mediaController.show();
}Example 43
| Project: mobile-spec-master File: VideoViewDemo.java View source code |
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.videoview);
mVideoView = (VideoView) findViewById(R.id.surface_view);
if (path == "") {
// Tell the user to provide a media file URL/path.
Toast.makeText(VideoViewDemo.this, "Please edit VideoViewDemo Activity, and set path" + " variable to your media file URL/path", Toast.LENGTH_LONG).show();
} else {
/*
* Alternatively,for streaming media you can use
* mVideoView.setVideoURI(Uri.parse(URLstring));
*/
mVideoView.setVideoPath(path);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
}
}Example 44
| Project: MUtils-master File: VideoActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mVideoContainer = new VideoContainer(this);
this.setContentView(mVideoContainer);
VideoView videoView = mVideoContainer.getVideoView();
mExtra = new VideoExtra();
if (mExtra.getFrom(getIntent())) {
videoView.setVideoURI(Uri.parse(mExtra.mUrl));
if (mExtra.mAutoPlay) {
videoView.start();
}
}
videoView.requestFocus();
}Example 45
| Project: OpenHAB_Room_Flipper-master File: OpenHABVideoWidget.java View source code |
@Override
public View getWidget() {
VideoView videoVideo = (VideoView) mViewData.widgetView.findViewById(R.id.videovideo);
Log.d(HABApplication.getLogTag(), "Opening video at " + mViewData.openHABWidget.getUrl());
// TODO: This is quite dirty fix to make video look maximum available size on all screens
WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
ViewGroup.LayoutParams videoLayoutParams = videoVideo.getLayoutParams();
videoLayoutParams.height = (int) (wm.getDefaultDisplay().getWidth() / 1.77);
videoVideo.setLayoutParams(videoLayoutParams);
// so we manage an array of all videos to stop them when user leaves the page
if (!mVideoWidgetList.contains(videoVideo))
mVideoWidgetList.add(videoVideo);
// Start video
if (!videoVideo.isPlaying()) {
videoVideo.setVideoURI(Uri.parse(mViewData.openHABWidget.getUrl()));
videoVideo.start();
}
Log.d(HABApplication.getLogTag(), "Video height is " + videoVideo.getHeight());
return mViewData.widgetView;
}Example 46
| Project: platform_development-master File: VideoViewDemo.java View source code |
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.videoview);
mVideoView = (VideoView) findViewById(R.id.surface_view);
if (path == "") {
// Tell the user to provide a media file URL/path.
Toast.makeText(VideoViewDemo.this, "Please edit VideoViewDemo Activity, and set path" + " variable to your media file URL/path", Toast.LENGTH_LONG).show();
} else {
/*
* Alternatively,for streaming media you can use
* mVideoView.setVideoURI(Uri.parse(URLstring));
*/
mVideoView.setVideoPath(path);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
}
}Example 47
| Project: ProgrammingAndroidExamples-master File: VideoRecorder.java View source code |
private void setupView() {
setContentView(R.layout.videorecorder);
findViewById(R.id.recordstop).setEnabled(false);
videoview = (VideoView) findViewById(R.id.videosurface);
final SurfaceHolder holder = videoview.getHolder();
holder.addCallback(this);
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
findViewById(R.id.recordstop).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
recordOrStop(holder);
}
});
findViewById(R.id.play).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
playVideo();
}
});
}Example 48
| Project: dash-master File: VideoView.java View source code |
@Override
public void run() {
try {
mCurrentState = STATE_PREPARING;
mPlayer.setDataSource(mSource, mVideoTrackIndex, mAudioTrackIndex);
if (mPlayer == null) {
// player has been release while the data source was set
return;
}
// Async prepare spawns another thread inside this thread which really isn't
// necessary; we call this method anyway because of the events it triggers
// when it fails, and to stay in sync which the Android VideoView that does
// the same.
mPlayer.prepareAsync();
Log.d(TAG, "video opened");
} catch (IOException e) {
Log.e(TAG, "video open failed", e);
exceptionHandler.sendEmptyMessage(0);
} catch (NullPointerException e) {
Log.e(TAG, "player released while preparing", e);
}
}Example 49
| Project: 3House-master File: VideoWidgetFactory.java View source code |
private void launchVideo() {
//Initializing the video player’s media controller.
MediaController controller = new MediaController(factory.getContext());
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
Log.d(TAG, "Load video widget on prepare");
mVideoView.getLayoutParams().height = (int) (((float) mp.getVideoWidth()) / mp.getVideoHeight()) * mVideoView.getLayoutParams().width;
mVideoView.requestLayout();
}
});
//OHBindingWrapper media controller with VideoView
mVideoView.setMediaController(controller);
}Example 50
| Project: android-app-common-tasks-master File: PickCaptureActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pick_capture);
ivPreview = (ImageView) findViewById(R.id.imageview_preview);
vvVideo = (VideoView) findViewById(R.id.videoview_preview);
TextView tvCaptureImage = (TextView) findViewById(R.id.captureimage);
TextView tvCaptureVideo = (TextView) findViewById(R.id.capturevideo);
TextView tvPickImage = (TextView) findViewById(R.id.pickimage);
TextView tvPickVideo = (TextView) findViewById(R.id.pickvideo);
tvCaptureImage.setOnClickListener(this);
tvCaptureVideo.setOnClickListener(this);
tvPickImage.setOnClickListener(this);
tvPickVideo.setOnClickListener(this);
}Example 51
| Project: AndroidExercise-master File: MainActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
videoView = (VideoView) findViewById(R.id.video_view);
play = (Button) findViewById(R.id.play);
pause = (Button) findViewById(R.id.pause);
replay = (Button) findViewById(R.id.replay);
play.setOnClickListener(this);
pause.setOnClickListener(this);
replay.setOnClickListener(this);
initVideoPath();
}Example 52
| Project: androidrocks-master File: PlayMedia.java View source code |
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
setContentView(R.layout.playmedia);
b = this.getIntent().getExtras();
if (b != null) {
path = b.getString("key");
}
Toast.makeText(PlayMedia.this, path, Toast.LENGTH_SHORT).show();
mVideoView = (VideoView) findViewById(R.id.video);
playButton = (Button) findViewById(R.id.play);
stopButton = (Button) findViewById(R.id.stop);
pauseButton = (Button) findViewById(R.id.pause);
resumeButton = (Button) findViewById(R.id.resume);
mVideoView.setMediaController(new MediaController(this));
playButton.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
try {
URL url = new URL(path);
URLConnection cn = url.openConnection();
cn.connect();
InputStream stream = cn.getInputStream();
if (stream == null) {
throw new RuntimeException("stream is null");
}
File temp = File.createTempFile("mediaplayertmp", "dat");
String tempPath = temp.getAbsolutePath();
FileOutputStream out = new FileOutputStream(temp);
byte[] buf = new byte[128];
do {
int numread = stream.read(buf);
if (numread <= 0) {
break;
}
out.write(buf, 0, numread);
} while (true);
mVideoView.setVideoURI(Uri.parse(tempPath));
mVideoView.requestFocus();
stream.close();
} catch (Exception ex) {
Toast.makeText(PlayMedia.this, "Illegal", Toast.LENGTH_SHORT).show();
}
}
});
stopButton.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
mVideoView.stopPlayback();
finish();
}
});
pauseButton.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
mVideoView.pause();
}
});
resumeButton.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
mVideoView.start();
}
});
Log.i("\n\nvideo", String.valueOf(mVideoView.isPlaying()));
}Example 53
| Project: android_frameworks_base-master File: VideoViewCaptureActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mVideoView = new VideoView(this);
mVideoView.setOnPreparedListener( mp -> {
mp.setLooping(true);
mVideoWidth = mp.getVideoWidth();
mVideoHeight = mp.getVideoHeight();
mVideoView.start();
});
Uri uri = Uri.parse("android.resource://com.android.test.hwui/" + R.raw.colorgrid_video);
mVideoView.setVideoURI(uri);
Button button = new Button(this);
button.setText("Copy bitmap to /sdcard/surfaceview.png");
button.setOnClickListener((View v) -> {
final Bitmap b = Bitmap.createBitmap(mVideoWidth, mVideoHeight, Bitmap.Config.ARGB_8888);
PixelCopy.request(mVideoView, b, (int result) -> {
if (result != PixelCopy.SUCCESS) {
Toast.makeText(VideoViewCaptureActivity.this, "Failed to copy", Toast.LENGTH_SHORT).show();
return;
}
try {
try (FileOutputStream out = new FileOutputStream(Environment.getExternalStorageDirectory() + "/surfaceview.png")) {
b.compress(Bitmap.CompressFormat.PNG, 100, out);
}
} catch (Exception e) {
}
}, mVideoView.getHandler());
});
FrameLayout content = new FrameLayout(this);
LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
layout.addView(button, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
layout.addView(mVideoView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
content.addView(layout, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
setContentView(content);
}Example 54
| Project: Anki-Android-master File: VideoPlayer.java View source code |
/** Called when the activity is first created. */
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.video_player);
mPath = getIntent().getStringExtra("path");
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
mVideoView = (VideoView) findViewById(R.id.video_surface);
mVideoView.getHolder().addCallback(this);
mSoundPlayer = new Sound();
}Example 55
| Project: booksource-master File: MainActivity.java View source code |
@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 {
// �始化MediaPlayer
initVideoPath();
}
}Example 56
| Project: common-app-master File: PickCaptureActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pick_capture);
ivPreview = (ImageView) findViewById(R.id.imageview_preview);
vvVideo = (VideoView) findViewById(R.id.videoview_preview);
TextView tvCaptureImage = (TextView) findViewById(R.id.captureimage);
TextView tvCaptureVideo = (TextView) findViewById(R.id.capturevideo);
TextView tvPickImage = (TextView) findViewById(R.id.pickimage);
TextView tvPickVideo = (TextView) findViewById(R.id.pickvideo);
tvCaptureImage.setOnClickListener(this);
tvCaptureVideo.setOnClickListener(this);
tvPickImage.setOnClickListener(this);
tvPickVideo.setOnClickListener(this);
}Example 57
| Project: Common-Sense-Net-2-master File: VideoPlayerActivity.java View source code |
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// sets the layout of the activity.
setContentView(R.layout.act_video_player);
ApplicationTracker.getInstance().logEvent(EventType.ACTIVITY_VIEW, Global.userId, this.getClass().getSimpleName());
// gets the extras to extract the select video from there.
Bundle extras = getIntent().getExtras();
// determines the path of the video to load based on the passed
// parameters.
String videoPath = null;
if (extras.containsKey(VideoActivity.SELECTED_VIDEO)) {
videoPath = extras.getString(VideoActivity.SELECTED_VIDEO);
}
// get the VideoView from the layout file
mVideoView = (VideoView) findViewById(R.id.video_player_videoview);
// use this to get touch events
mVideoView.requestFocus();
// set the video URI, passing the video source path as an URI
mVideoView.setVideoURI(Uri.parse(videoPath));
// creates a new MediaController
MediaController mediaController = new MediaController(this) {
@Override
public void show() {
super.show(0);
}
};
mediaController.setAnchorView(mVideoView);
// sets the media controller.
mVideoView.setMediaController(mediaController);
// plays the video.
mVideoView.start();
// makes it always visible.
// mediaController.show(0);
// listens to the back button event.
final Button video_back = (Button) findViewById(R.id.video_player_button_back);
video_back.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
ApplicationTracker.getInstance().logEvent(EventType.CLICK, Global.userId, this.getClass().getSimpleName(), "back");
startActivity(new Intent(VideoPlayerActivity.this, VideoActivity.class));
VideoPlayerActivity.this.finish();
}
});
}Example 58
| Project: Dumpert-master File: VideoActivity.java View source code |
void start(String url) {
final View videoViewFrame = findViewById(R.id.video_frame);
final VideoView videoView = (VideoView) findViewById(R.id.video);
videoView.setVideoURI(Uri.parse(url));
mediaController = new MediaController(this) {
@Override
public void hide() {
super.hide();
setNavVisibility(false);
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
//mediacontroller tries some funny stuff here, so use SUPER HACKY METHODS! yay!
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK)
onBackPressed();
return false;
}
};
mediaController.setAnchorView(videoViewFrame);
videoView.setMediaController(mediaController);
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
Log.d("dumpert.video", "onPrepared");
findViewById(R.id.loading).setVisibility(View.GONE);
}
});
videoView.setOnErrorListener(new MediaPlayer.OnErrorListener() {
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
findViewById(R.id.loading).setVisibility(View.GONE);
Snackbar.with(VideoActivity.this).text(R.string.video_failed).textColor(Color.parseColor("#FFCDD2")).show(VideoActivity.this);
return true;
}
});
setNavVisibility(false);
videoView.start();
}Example 59
| Project: feeddroid-master File: PodcastPlayerActivity.java View source code |
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.media_player);
Intent intent = getIntent();
String url = intent.getStringExtra("url");
String name = intent.getStringExtra("name");
String type = intent.getStringExtra("type");
TextView title = (TextView) findViewById(R.id.podcast_name);
title.setText(name);
if (type.startsWith("audio")) {
ImageView image = new ImageView(this);
image.setBackgroundDrawable(getResources().getDrawable(R.drawable.rssred256));
image.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
}
VideoView player = (VideoView) findViewById(R.id.podcast_player);
player.setKeepScreenOn(true);
player.setVideoURI(Uri.parse(url));
MediaController controller = new MediaController(this);
player.setMediaController(controller);
player.requestFocus();
player.start();
controller.show(10000);
}Example 60
| Project: gina-puffinfeeder-android-viewer-master File: FullscreenVideoPlayerActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fullscreen_video_player);
movie = (VideoView) findViewById(R.id.fullscreen_content);
movie.setOnSystemUiVisibilityChangeListener(new SysUiVisibilityListener());
movie.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.setLooping(true);
}
});
if (getIntent().getExtras() != null)
movie.setVideoPath(getIntent().getExtras().getString("url"));
else
movie.setVideoPath("http://feeder.gina.alaska.edu/feeds/radar-uaf-barrow-seaice-images/movies/3464_radar-uaf-barrow-seaice-images_2014-6-5_1-day-animation.webm");
MC = new MediaController(this);
MC.setAnchorView(movie);
movie.setMediaController(MC);
movie.start();
}Example 61
| Project: jaankari-master File: ResultViewer.java View source code |
protected int launchResult(SearchResults result) {
if ("Video".equals(result.getCategory())) {
DatabaseHandler db = new DatabaseHandler(getApplicationContext());
// Intent intent = new Intent();
// intent.setAction(android.content.Intent.ACTION_VIEW);
//
// Videos video = db.getVideobyId(result.getId());
//
// File file = new File(db.getFilePath(result.getCategory(), result.getId()));
//
// Log.d(TAG, db.getFilePath(result.getCategory(), result.getId()));
// intent.setDataAndType(Uri.fromFile(file), "video/*");
//startActivity(intent);
VideoView vidView = (VideoView) findViewById(R.id.myVideo);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
MediaController vidControl = new MediaController(this);
vidControl.setAnchorView(vidView);
vidView.setMediaController(vidControl);
vidView.setVideoPath(db.getFilePath(result.getCategory(), result.getId()));
vidView.start();
db.closeDB();
} else {
}
return 0;
}Example 62
| Project: LQRViedoRecordView-master File: SuccessActivity.java View source code |
//�始化
private void init() {
text = (TextView) findViewById(R.id.text);
button1 = (Button) findViewById(R.id.button1);
button2 = (Button) findViewById(R.id.button2);
button3 = (Button) findViewById(R.id.button3);
button4 = (Button) findViewById(R.id.button4);
videoView1 = (VideoView) findViewById(R.id.videoView1);
}Example 63
| Project: MediaPicker-master File: VideoFragment.java View source code |
private void init(View view) {
// Find our View instances
videoView = (VideoView) view.findViewById(R.id.iv_video);
MediaController mediaController = new MediaController(getActivity());
mediaController.setAnchorView(videoView);
videoView.setMediaController(mediaController);
videoView.start();
path = (TextView) view.findViewById(R.id.tv_path);
view.findViewById(R.id.bt_pick).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pickVideo();
}
});
}Example 64
| Project: photo-picker-plus-android-master File: VideoPlayerActivity.java View source code |
private void initVideo(String url) {
videoView = (VideoView) findViewById(R.id.videoView);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
Uri uri = Uri.parse(url);
videoView.setMediaController(mediaController);
videoView.setVideoURI(uri);
videoView.requestFocus();
videoView.start();
}Example 65
| Project: pictureADay-master File: VideoDemoActivity.java View source code |
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
setContentView(R.layout.video);
albumName = getIntent().getStringExtra("albumName");
SharedPreferences preferences = getSharedPreferences(Utilities.PIC_STORE, 0);
videoId = preferences.getString(albumName + ".videoId", "http://commonsware.com/misc/test2.3gp");
Log.d(TAG, "albumName: " + albumName + " videoId: " + videoId);
// File clip=new File(Environment.getExternalStorageDirectory(),
// "test.mp4");
String videoUrl = "http://server.autburst.com/movies/" + videoId + "/" + albumName + ".mp4";
Log.d(TAG, "videoUrl for Preview: " + videoUrl);
Uri uri = Uri.parse(videoUrl);
// if (clip.exists()) {
video = (VideoView) findViewById(R.id.videoView);
// video.setVideoPath(clip.getAbsolutePath());
video.setVideoURI(uri);
ctlr = new MediaController(this);
ctlr.setMediaPlayer(video);
video.setMediaController(ctlr);
video.requestFocus();
video.start();
// }
}Example 66
| Project: platform_frameworks_base-master File: VideoViewCaptureActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mVideoView = new VideoView(this);
mVideoView.setOnPreparedListener( mp -> {
mp.setLooping(true);
mVideoWidth = mp.getVideoWidth();
mVideoHeight = mp.getVideoHeight();
mVideoView.start();
});
Uri uri = Uri.parse("android.resource://com.android.test.hwui/" + R.raw.colorgrid_video);
mVideoView.setVideoURI(uri);
Button button = new Button(this);
button.setText("Copy bitmap to /sdcard/surfaceview.png");
button.setOnClickListener((View v) -> {
final Bitmap b = Bitmap.createBitmap(mVideoWidth, mVideoHeight, Bitmap.Config.ARGB_8888);
PixelCopy.request(mVideoView, b, (int result) -> {
if (result != PixelCopy.SUCCESS) {
Toast.makeText(VideoViewCaptureActivity.this, "Failed to copy", Toast.LENGTH_SHORT).show();
return;
}
try {
try (FileOutputStream out = new FileOutputStream(Environment.getExternalStorageDirectory() + "/surfaceview.png")) {
b.compress(Bitmap.CompressFormat.PNG, 100, out);
}
} catch (Exception e) {
}
}, mVideoView.getHandler());
});
FrameLayout content = new FrameLayout(this);
LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
layout.addView(button, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
layout.addView(mVideoView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
content.addView(layout, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
setContentView(content);
}Example 67
| Project: ttr-master File: MediaPlayerActivity.java View source code |
@Override
protected void onCreate(Bundle instance) {
setTheme(Controller.getInstance().getTheme());
super.onCreate(instance);
mDamageReport.initialize();
setContentView(R.layout.media);
Bundle extras = getIntent().getExtras();
String url;
if (extras != null) {
url = extras.getString(URL);
} else if (instance != null) {
url = instance.getString(URL);
} else {
url = "";
}
VideoView videoView = (VideoView) findViewById(R.id.MediaView);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
Uri video = Uri.parse(url);
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();
}Example 68
| Project: ttrss-reader-fork-master File: MediaPlayerActivity.java View source code |
@Override
protected void onCreate(Bundle instance) {
setTheme(Controller.getInstance().getTheme());
super.onCreate(instance);
mDamageReport.initialize();
setContentView(R.layout.media);
Bundle extras = getIntent().getExtras();
String url;
if (extras != null) {
url = extras.getString(URL);
} else if (instance != null) {
url = instance.getString(URL);
} else {
url = "";
}
VideoView videoView = (VideoView) findViewById(R.id.MediaView);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
Uri video = Uri.parse(url);
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();
}Example 69
| Project: yt-direct-lite-android-master File: ReviewActivity.java View source code |
private void reviewVideo(Uri mFileUri) {
try {
mVideoView = (VideoView) findViewById(R.id.videoView);
mc = new MediaController(this);
mVideoView.setMediaController(mc);
mVideoView.setVideoURI(mFileUri);
mc.show();
mVideoView.start();
} catch (Exception e) {
Log.e(this.getLocalClassName(), e.toString());
}
}Example 70
| Project: adaptive-arp-android-master File: VideoActivity.java View source code |
/**
* Called when the activity is starting.
*
* @param savedInstanceState If the activity is being re-initialized after previously being shut
* down then this Bundle contains the data it most recently supplied
* in onSaveInstanceState(Bundle). Note: Otherwise it is null.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Uri uri = Uri.parse(getIntent().getStringExtra("url"));
//TODO validate
logger.log(ILoggingLogLevel.Info, LOG_TAG, "Stating Video Activity with uri: " + uri);
// animation
overridePendingTransition(R.anim.right_slide_in, R.anim.fade_out);
setContentView(R.layout.activity_video);
// remove title
//this.requestWindowFeature(Window.FEATURE_NO_TITLE);
// remove notification bar
//this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
// dialog
dialog = new ProgressDialog(this, R.style.MyTheme);
dialog.setCancelable(false);
dialog.setProgressStyle(android.R.style.Widget_ProgressBar_Small);
dialog.show();
// VideoView
final VideoView videoView = (VideoView) findViewById(R.id.videoView);
videoView.setVideoURI(uri);
MediaController mediaController = new MediaController(this);
videoView.setMediaController(mediaController);
mediaController.show();
// listener fired when the video is fully loaded
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
logger.log(ILoggingLogLevel.Debug, LOG_TAG, "setOnPreparedListener video");
dialog.hide();
dialog.dismiss();
videoView.start();
}
});
// listener fired when the video finishes
videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
logger.log(ILoggingLogLevel.Debug, LOG_TAG, "setOnCompletionListener video");
selfDestruct();
}
});
}Example 71
| Project: Alpha-Moon-master File: VideoViewerActivity.java View source code |
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Setting up full screen mode for kisok mode
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
//////////////
setContentView(R.layout.video_viewer);
String content = getIntent().getExtras().getString("content");
this.nodeId = getIntent().getExtras().getInt("node_id");
this.contentId = getIntent().getExtras().getInt("content_id");
this.skillId = getIntent().getExtras().getInt("skill_id");
Log.v("Video_Id", "Video_Id" + this.nodeId);
//setting start event for video in database
db = new DatabaseHelper(this);
db.createVideoConsumptionSessionEvent(this.contentId, this.nodeId, this.skillId, "start");
this.isActivityStarted = true;
//assign video path and start playing
this.videoView = (VideoView) findViewById(R.id.videoViewComponent);
String path = "android.resource://" + getPackageName() + "/" + "raw/" + content;
videoView.setVideoURI(Uri.parse(path));
videoView.start();
videoView.setOnCompletionListener(new VideoCompleteListener(this));
}Example 72
| Project: android-testdpc-master File: MediaDisplayFragment.java View source code |
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_media_display, container, false);
switch(mDisplayRequest) {
case REQUEST_DISPLAY_IMAGE:
ImageView imageView = (ImageView) view.findViewById(R.id.image);
imageView.setImageURI(mMediaUri);
imageView.setVisibility(View.VISIBLE);
break;
case REQUEST_DISPLAY_VIDEO:
final VideoView videoView = (VideoView) view.findViewById(R.id.video);
videoView.setVideoURI(mMediaUri);
videoView.setVisibility(View.VISIBLE);
videoView.requestFocus();
Button playButton = (Button) view.findViewById(R.id.play_button);
playButton.setVisibility(View.VISIBLE);
playButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
videoView.start();
}
});
Button stopButton = (Button) view.findViewById(R.id.stop_button);
stopButton.setVisibility(View.VISIBLE);
stopButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
videoView.pause();
}
});
break;
}
Button deleteButton = (Button) view.findViewById(R.id.delete_button);
deleteButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
getActivity().getContentResolver().delete(mMediaUri, null, null);
getActivity().getFragmentManager().popBackStack();
}
});
return view;
}Example 73
| Project: androidtv-Leanback-master File: Utils.java View source code |
/**
* Example for handling resizing content for overscan. Typically you won't need to resize when
* using the Leanback support library.
*/
public void overScan(Activity activity, VideoView videoView) {
DisplayMetrics metrics = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
int w = (int) (metrics.widthPixels * MediaDimensions.MEDIA_WIDTH);
int h = (int) (metrics.heightPixels * MediaDimensions.MEDIA_HEIGHT);
int marginLeft = (int) (metrics.widthPixels * MediaDimensions.MEDIA_LEFT_MARGIN);
int marginTop = (int) (metrics.heightPixels * MediaDimensions.MEDIA_TOP_MARGIN);
int marginRight = (int) (metrics.widthPixels * MediaDimensions.MEDIA_RIGHT_MARGIN);
int marginBottom = (int) (metrics.heightPixels * MediaDimensions.MEDIA_BOTTOM_MARGIN);
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(w, h);
lp.setMargins(marginLeft, marginTop, marginRight, marginBottom);
videoView.setLayoutParams(lp);
}Example 74
| Project: Android_Example_Projects-master File: VideoActivity.java View source code |
public void onPlayLocalVideo(View v) {
VideoView mVideoView = (VideoView) findViewById(R.id.video_view);
mVideoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.small_video));
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
mVideoView.start();
}Example 75
| Project: Cloudesk-master File: CurtainActivity.java View source code |
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
strVideoPath = this.getIntent().getStringExtra("videoPath");
//去掉头信�
this.CurrentActivity = this;
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Bundle bundle = this.getIntent().getExtras();
//åˆ¤æ–æ‰‹æœºå±?幕的方å?‘
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
width = dm.widthPixels;
heigh = dm.heightPixels;
setContentView(R.layout.curtain);
//横�
mVideoView = (VideoView) findViewById(R.id.videoView1);
// mVideoView.setBackgroundDrawable(getWallpaper());
mVideoView.setVideoPath(strVideoPath);
MediaController controller = new MediaController(this);
mVideoView.setMediaController(controller);
mVideoView.requestFocus();
mVideoView.setOnPreparedListener(new OnPreparedListener() {
// å¼€å§‹æ’æ”¾
@Override
public void onPrepared(MediaPlayer mp) {
mVideoView.setBackgroundColor(Color.argb(0, 0, 255, 0));
}
});
//æ’æ”¾å®Œæ¯•
mVideoView.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
}
});
}Example 76
| Project: curso-avanzado-android-master File: VideoPlayerActivity.java View source code |
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
videos = new ArrayList<VideoView>();
vista1 = (VideoView) findViewById(R.id.videoView1);
vista2 = (VideoView) findViewById(R.id.videoView2);
vista3 = (VideoView) findViewById(R.id.videoView3);
vista4 = (VideoView) findViewById(R.id.videoView4);
vista5 = (VideoView) findViewById(R.id.videoView5);
vista6 = (VideoView) findViewById(R.id.videoView6);
videos.add(vista1);
videos.add(vista2);
videos.add(vista3);
videos.add(vista4);
videos.add(vista5);
videos.add(vista6);
urls = new ArrayList<String>();
urls.add("rtsp://v5.cache3.c.youtube.com/CiILENy73wIaGQmJpIH6s-gCvRMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp");
urls.add("rtsp://v1.cache1.c.youtube.com/CiILENy73wIaGQlI28H9wT_t1RMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp");
urls.add("rtsp://v1.cache2.c.youtube.com/CiILENy73wIaGQmAnU4e9TLq5RMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp");
urls.add("rtsp://v7.cache1.c.youtube.com/CiILENy73wIaGQlkj-8U0R7r0xMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp");
urls.add("rtsp://v7.cache8.c.youtube.com/CiILENy73wIaGQmsObW1caaIhxMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp");
urls.add("rtsp://v7.cache2.c.youtube.com/CiILENy73wIaGQlXuZR407T8rBMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp");
}Example 77
| Project: DeviceConnect-Android-master File: VideoPlayer.java View source code |
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// タイトルを�表示
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.video_player);
mVideoView = (VideoView) findViewById(R.id.videoView);
// �生�るVideo�URI
Intent mIntent = this.getIntent();
mUri = mIntent.getData();
}Example 78
| Project: emobc-android-master File: VideoActivityGenerator.java View source code |
@Override
protected void loadAppLevelData(final Activity activity, final AppLevelData data) {
final VideoLevelDataItem item = (VideoLevelDataItem) data.findByNextLevel(nextLevel);
//rotateScreen(activity);
initializeHeader(activity, item);
//Create Banner
CreateMenus c = (CreateMenus) activity;
c.createBanner();
if (Utils.hasLength(item.getVideoPath())) {
if (Utils.isUrl(item.getVideoPath())) {
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(item.getVideoPath())));
activity.finish();
} else {
Log.d("URL", item.getVideoPath());
VideoView video = (VideoView) activity.findViewById(R.id.video);
video.setVideoURI(Uri.parse(item.getVideoPath()));
MediaController mc = new MediaController(activity);
video.setMediaController(mc);
video.requestFocus();
video.start();
mc.show();
}
}
}Example 79
| Project: iFixitAndroid-master File: VideoViewActivity.java View source code |
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle extras = getIntent().getExtras();
String videoUrl = extras.getString(VIDEO_URL);
boolean isOffline = extras.getBoolean(IS_OFFLINE);
requestWindowFeature((int) Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.video_view);
mVideoView = (VideoView) findViewById(R.id.video_view);
MediaController mc = new MediaController(this);
mVideoView.setMediaController(mc);
if (isOffline) {
mVideoView.setVideoPath(ApiSyncAdapter.getOfflineMediaPath(videoUrl));
} else {
mVideoView.setVideoURI(Uri.parse(videoUrl));
}
mProgressDialog = ProgressDialog.show(this, getString(R.string.video_activity_progress_title), getString(R.string.video_activity_progress_body), true);
mVideoView.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
if (mProgressDialog != null)
mProgressDialog.dismiss();
mVideoView.requestFocus();
mp.start();
}
});
mVideoView.setOnCompletionListener(new OnCompletionListener() {
MediaPlayer mMediaPlayer;
@Override
public void onCompletion(MediaPlayer mp) {
mMediaPlayer = mp;
AlertDialog.Builder restartDialog = new AlertDialog.Builder(VideoViewActivity.this);
restartDialog.setTitle(getString(R.string.restart_video));
restartDialog.setMessage(getString(R.string.restart_video_message)).setCancelable(true).setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// Reset the video player and restart the clip
mMediaPlayer.seekTo(0);
mMediaPlayer.start();
}
}).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// close the dialog box and go back to the guide step
dialog.cancel();
finish();
}
});
restartDialog.create().show();
}
});
}Example 80
| Project: KinoCast-master File: PlayerActivity.java View source code |
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
final View controlsView = findViewById(R.id.fullscreen_content_controls);
final VideoView videoView = (VideoView) findViewById(R.id.fullscreen_content);
videoView.setVideoURI(mVideoUri);
final FrameLayout decor = (FrameLayout) getWindow().getDecorView();
final View videoProgressView = View.inflate(getApplicationContext(), R.layout.video_loading_progress, null);
decor.addView(videoProgressView);
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
decor.removeView(videoProgressView);
videoView.setMediaController(mMediaController);
mMediaController.setAnchorView(controlsView);
}
});
videoView.setOnErrorListener(new MediaPlayer.OnErrorListener() {
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
(new AlertDialog.Builder(PlayerActivity.this)).setTitle(getString(R.string.player_error_dialog_title)).setMessage(getString(R.string.player_unsupported_format) + "\n\n(#" + what + "E" + extra + ")").setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
}).show();
return true;
}
});
videoView.start();
delayedHide(100);
}Example 81
| Project: MyGoproRemote-master File: PreviewActivity.java View source code |
private void PlayVideo() {
try {
final VideoView videoView = (VideoView) findViewById(R.id.videoView1);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
Uri video = Uri.parse("http://10.5.5.9:8080/live/amba.m3u8");
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.setMediaController(null);
videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
mp.stop();
PlayVideo();
}
});
videoView.setOnErrorListener(new OnErrorListener() {
public boolean onError(MediaPlayer mp, int what, int extra) {
return true;
}
});
videoView.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
videoView.start();
}
});
} catch (Exception e) {
System.out.println("Video Play Error :" + e.toString());
finish();
}
}Example 82
| Project: PictureSelector-master File: PictureVideoPlayActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
super.onCreate(savedInstanceState);
setContentView(R.layout.picture_activity_video_play);
video_path = getIntent().getStringExtra("video_path");
picture_left_back = (ImageView) findViewById(R.id.picture_left_back);
mVideoView = (VideoView) findViewById(R.id.video_view);
// è§£å†³æ’æ”¾è§†é¢‘é€?明问题
mVideoView.setZOrderOnTop(true);
iv_play = (ImageView) findViewById(R.id.iv_play);
mMediaController = new MediaController(this);
mVideoView.setOnCompletionListener(this);
mVideoView.setOnPreparedListener(this);
mVideoView.setMediaController(mMediaController);
picture_left_back.setOnClickListener(this);
iv_play.setOnClickListener(this);
}Example 83
| Project: Project-Libre-master File: HttpChatAction.java View source code |
@Override
protected void onPostExecute(String xml) {
if (this.config.disconnect) {
return;
}
super.onPostExecute(xml);
if (this.exception != null) {
MainActivity.error(this.exception.getMessage(), this.exception, this.activity);
return;
}
try {
MainActivity.conversation = this.response.conversation;
final ChatActivity activity = (ChatActivity) this.activity;
ImageView imageView = (ImageView) activity.findViewById(R.id.imageView);
final VideoView videoView = (VideoView) activity.findViewById(R.id.videoView);
View videoLayout = activity.findViewById(R.id.videoLayout);
if (MainActivity.sound && this.response.avatarActionAudio != null && this.response.avatarActionAudio.length() > 0) {
// Action audio
activity.playAudio(this.response.avatarActionAudio, false, true, true);
}
if (MainActivity.sound && this.response.avatarAudio != null && this.response.avatarAudio.length() > 0) {
// Background audio
if (!this.response.avatarAudio.equals(activity.currentAudio)) {
if (activity.audioPlayer != null) {
activity.audioPlayer.stop();
activity.audioPlayer.release();
}
activity.audioPlayer = activity.playAudio(this.response.avatarAudio, true, true, true);
}
} else if (activity.audioPlayer != null) {
activity.audioPlayer.stop();
activity.audioPlayer.release();
activity.audioPlayer = null;
}
if (!MainActivity.disableVideo && !activity.videoError && this.response.isVideo()) {
// Video avatar
if (imageView.getVisibility() != View.GONE || videoLayout.getVisibility() != View.GONE) {
if (imageView.getVisibility() == View.VISIBLE) {
imageView.setVisibility(View.GONE);
}
if (videoLayout.getVisibility() == View.GONE) {
videoLayout.setVisibility(View.VISIBLE);
}
}
if (this.response.avatarAction != null && this.response.avatarAction.length() > 0) {
// Action video
videoView.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.setLooping(false);
}
});
videoView.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
activity.resetVideoErrorListener();
videoView.setOnCompletionListener(null);
activity.playVideo(response.avatar, true);
activity.response(response);
}
});
videoView.setOnErrorListener(new OnErrorListener() {
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
activity.resetVideoErrorListener();
activity.playVideo(response.avatar, true);
activity.response(response);
return true;
}
});
activity.playVideo(this.response.avatarAction, false);
return;
} else {
activity.playVideo(this.response.avatar, true);
}
} else {
// Image avatar
if (imageView.getVisibility() != View.GONE || videoLayout.getVisibility() != View.GONE) {
if (imageView.getVisibility() == View.GONE) {
imageView.setVisibility(View.VISIBLE);
}
if (videoLayout.getVisibility() == View.VISIBLE) {
videoLayout.setVisibility(View.GONE);
}
}
if (response.isVideo()) {
HttpGetImageAction.fetchImage(this.activity, MainActivity.instance.avatar, imageView);
} else {
HttpGetImageAction.fetchImage(this.activity, this.response.avatar, imageView);
}
}
activity.response(this.response);
} catch (Exception error) {
this.exception = error;
MainActivity.error(this.exception.getMessage(), this.exception, this.activity);
return;
}
}Example 84
| Project: qiniu-lab-android-master File: AudioVideoPlayUseVideoViewActivity.java View source code |
private void initVideoPlay() {
this.videoPlayController = new MediaController(this);
this.videoPlayView = (VideoView) this.findViewById(R.id.simple_video_play_videoview);
this.videoPlayLogTextView = (TextView) this.findViewById(R.id.simple_video_play_log_textview);
videoPlayView.setMediaController(videoPlayController);
videoPlayController.setMediaPlayer(videoPlayView);
videoPlayController.setAnchorView(videoPlayView);
final String videoName = this.getIntent().getStringExtra("VideoName");
final String adsUrl = this.getIntent().getStringExtra("AdsUrl");
final String videoUrl = this.getIntent().getStringExtra("VideoUrl");
this.setTitle(videoName);
final long startTime = System.currentTimeMillis();
//common settings
videoPlayView.setOnErrorListener(new MediaPlayer.OnErrorListener() {
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
videoPlayLogTextView.append("Error, Pos" + mp.getCurrentPosition() + "\r\n");
return false;
}
});
if (!adsUrl.isEmpty()) {
///////////////// Play the ads first /////////////////////////
videoPlayView.setVideoURI(Uri.parse(adsUrl));
videoPlayView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
long duration = videoPlayView.getDuration();
long endTime = System.currentTimeMillis();
long loadTime = endTime - startTime;
videoPlayLogTextView.append("Load Ads Time: " + Tools.formatMilliSeconds(loadTime) + ", Duration: " + duration + "ms\r\n");
mp.start();
}
});
//////////////////Play the video then ////////////////////////
//video to play
videoPlayView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
videoPlayView.setVideoURI(Uri.parse(videoUrl));
final long startTime2 = System.currentTimeMillis();
videoPlayView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
long duration = videoPlayView.getDuration();
long endTime = System.currentTimeMillis();
long loadTime = endTime - startTime2;
videoPlayLogTextView.append("Load Video Time: " + Tools.formatMilliSeconds(loadTime) + ", Duration:" + duration + "ms\r\n");
mp.start();
}
});
videoPlayView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
videoPlayLogTextView.append("All Play Ends\r\n");
}
});
}
});
} else {
//video to play
videoPlayView.setVideoURI(Uri.parse(videoUrl));
final long startTime2 = System.currentTimeMillis();
videoPlayView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
long duration = videoPlayView.getDuration();
long endTime = System.currentTimeMillis();
long loadTime = endTime - startTime2;
videoPlayLogTextView.append("Load Video Time: " + Tools.formatMilliSeconds(loadTime) + ", Duration:" + duration + "ms\r\n");
mp.start();
}
});
videoPlayView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
videoPlayLogTextView.append("All Play Ends\r\n");
}
});
}
}Example 85
| Project: RecordVideo-master File: PreviewFragment.java View source code |
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
videoView = (VideoView) view.findViewById(R.id.videoView);
ImageView back = (ImageView) view.findViewById(R.id.record_back);
TextView next = (TextView) view.findViewById(R.id.record_next);
play = (ImageView) view.findViewById(R.id.record_play);
back.setOnClickListener(this);
next.setOnClickListener(this);
play.setOnClickListener(this);
mInterface = (BaseCaptureInterface) getActivity();
if (uri != null && !uri.equals("")) {
videoView.setVideoURI(Uri.parse(uri));
videoView.start();
} else {
Toast.makeText(getActivity(), "视频地�错误", Toast.LENGTH_SHORT).show();
}
videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
play.setVisibility(View.VISIBLE);
}
});
}Example 86
| Project: rpi_wakeup_light-master File: AlarmActivity.java View source code |
private void startAlarm() {
vv = (VideoView) findViewById(R.id.videoView);
vv.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
// Keep the video on continuous loop
mp.setLooping(true);
}
});
// Load the video from internal APK resources
Uri video = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.wake_up_dance);
vv.setVideoURI(video);
vv.start();
// Load Alarm sound from shared preferences
SharedPreferences prefs = getSharedPreferences(Constants.PREFS_NAME, MODE_PRIVATE);
String notySoundUri = prefs.getString("noty_sound_uri", RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM).toString());
SharedPreferences.Editor editor = prefs.edit();
editor.remove("alarm_time");
editor.commit();
try {
// Play alarm tone in a continuous loop
ringtone = new MediaPlayer();
ringtone.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.start();
}
});
ringtone.setDataSource(getApplicationContext(), Uri.parse(notySoundUri));
ringtone.setLooping(true);
ringtone.setAudioStreamType(AudioManager.STREAM_ALARM);
ringtone.prepareAsync();
} catch (IOException ex) {
}
}Example 87
| Project: VideoEdit-master File: PreviewFragment.java View source code |
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
videoView = (VideoView) view.findViewById(R.id.videoView);
ImageView back = (ImageView) view.findViewById(R.id.record_back);
TextView next = (TextView) view.findViewById(R.id.record_next);
play = (ImageView) view.findViewById(R.id.record_play);
back.setOnClickListener(this);
next.setOnClickListener(this);
play.setOnClickListener(this);
mInterface = (BaseCaptureInterface) getActivity();
if (uri != null && !uri.equals("")) {
videoView.setVideoURI(Uri.parse(uri));
videoView.start();
} else {
Toast.makeText(getActivity(), "视频地�错误", Toast.LENGTH_SHORT).show();
}
videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
play.setVisibility(View.VISIBLE);
}
});
}Example 88
| Project: YARR-master File: GfyPostPage.java View source code |
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_post_page_gfy, container, false);
// against id collisions
view.setId(((Object) this).hashCode());
TextView postTitle = (TextView) view.findViewById(R.id.post_title);
videoView = (VideoView) view.findViewById(R.id.video_view);
Fab fab = (Fab) view.findViewById(R.id.reddit_comment_fab);
String url = "";
try {
postTitle.setText(postObject.getJSONObject("data").getString("title"));
url = postObject.getJSONObject("data").getString("url");
} catch (JSONException e) {
e.printStackTrace();
}
postTitle.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
Anim.collapse(view);
return true;
}
});
new HttpAsyncTask() {
protected void onPostExecute(String result) {
SetGfyJson(result);
}
}.execute(toApiURL(url));
return view;
}Example 89
| Project: AnBox-master File: RecordViewerActivity.java View source code |
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
videoHolder = (VideoView) findViewById(R.id.RecordView);
if (currentlyPlaying.compareTo(list.elementAt(position).containingFile) != 0) {
videoHolder.stopPlayback();
String movieFilePath = list.elementAt(position).getMovieFilePath();
videoHolder.setVideoURI(Uri.parse("file://" + movieFilePath));
videoHolder.requestFocus();
}
int startTime = (int) (list.elementAt(position).occurredAt - 10 * 1000 - Config.getTimeFromFileName(list.elementAt(position).containingFile));
if (startTime < 0)
startTime = 0;
videoHolder.seekTo(startTime);
videoHolder.start();
currentlyPlaying = list.elementAt(position).containingFile;
}Example 90
| Project: Android-Demo-Projects-master File: VideoPlayerActivity.java View source code |
protected void initViews() {
mSpinningProgressBar = (ProgressBar) findViewById(R.id.progress_spinner);
mVideoView = (VideoView) findViewById(R.id.video_view);
mVideoView.setOnCompletionListener(onCompletionListener);
mVideoView.setOnErrorListener(onErrorListener);
mVideoView.setOnPreparedListener(onPreparedListener);
if (mVideoView == null) {
throw new IllegalArgumentException("Layout must contain a video view with ID video_view");
}
mUri = Uri.parse(getIntent().getExtras().getString(EXTRA_VIDEO_URL));
mVideoView.setVideoURI(mUri);
}Example 91
| Project: Android-Funny-Feed-master File: ItemFeedMovie.java View source code |
@Override
public View getView(LayoutInflater inflater, View convertView) {
if (convertView == null) {
convertView = (View) inflater.inflate(R.layout.list_feed_movie, null);
}
tvCaption = (TextView) convertView.findViewById(R.id.txtCaption);
viewVideo = (VideoView) convertView.findViewById(R.id.vvVideo);
final ProgressBar progressBar = (ProgressBar) convertView.findViewById(R.id.progressPhoto);
try {
String caption = feed.getString("description");
tvCaption.setText(caption);
////////////////////////////////////////////////////
ParseFile videoFile = (ParseFile) feed.get("movie");
String key = feed.getObjectId();
String urlPath = videoFile.getUrl();
String extension = urlPath.substring((urlPath.lastIndexOf(".") + 1), urlPath.length());
final String url = key + "." + extension;
if (viewVideo.isPlaying()) {
return convertView;
}
viewVideo.setVisibility(View.INVISIBLE);
videoFile.getDataInBackground(new GetDataCallback() {
@Override
public void done(byte[] data, ParseException e) {
// TODO Auto-generated method stub
if (e == null) {
progressBar.setVisibility(View.GONE);
writeByteToFile(url, data);
String filePath = Environment.getExternalStorageDirectory() + "/FunnyFeed/" + url;
viewVideo.setVisibility(View.VISIBLE);
viewVideo.setVideoPath(filePath);
// viewVideo.setMediaController(new MediaController(m_context));
viewVideo.setOnErrorListener(new OnErrorListener() {
@Override
public boolean onError(MediaPlayer arg0, int arg1, int arg2) {
return false;
}
});
viewVideo.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
if (!viewVideo.isPlaying()) {
viewVideo.requestFocus();
viewVideo.start();
mp.setLooping(true);
}
}
});
} else {
// something went wrong
}
}
}, new ProgressCallback() {
@Override
public void done(Integer arg0) {
// TODO Auto-generated method stub
progressBar.setProgress(arg0);
}
});
} catch (Exception e) {
e.printStackTrace();
}
return convertView;
}Example 92
| Project: android-search-and-stories-master File: DDGWebChromeClient.java View source code |
@Override
public void onShowCustomView(View view, CustomViewCallback callback) {
if (view instanceof FrameLayout) {
FrameLayout layout = (FrameLayout) view;
View focusedChild = layout.getFocusedChild();
this.isVideoFullscreen = true;
this.videoViewContainer = layout;
this.videoViewCallback = callback;
hideContent.setVisibility(View.INVISIBLE);
showContent.addView(videoViewContainer, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
showContent.setVisibility(View.VISIBLE);
if (focusedChild instanceof VideoView) {
VideoView videoView = (VideoView) focusedChild;
videoView.setOnCompletionListener(this);
videoView.setOnErrorListener(this);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
addFullscreenFlag();
}
}
}Example 93
| Project: android4tv-app-v2-master File: OverlayPlayer.java View source code |
private void createVideoView() {
if (mVideoView != null) {
clearVideoView();
}
mVideoView = new VideoView(mContext);
mVideoView.setLayoutParams(new RelativeLayout.LayoutParams(video_w, video_h));
mOverlayLayer.setX(video_x);
mOverlayLayer.setY(video_y);
mVideoView.setVisibility(View.VISIBLE);
mVideoView.setZOrderOnTop(true);
mVideoView.setZOrderMediaOverlay(false);
mVideoView.invalidate();
mOverlayLayer.addView(mVideoView);
// borders!
mOverlayLayer.setLayoutParams(new RelativeLayout.LayoutParams(video_w + 10, video_h + 10));
mVideoView.setX(5);
mVideoView.setY(5);
mOverlayLayer.requestLayout();
mVideoView.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
Log.d(TAG, "onPrepare");
mVideoView.start();
Parcel request = Parcel.obtain();
request.writeInt(video_x);
request.writeInt(video_y);
request.writeInt(video_w);
request.writeInt(video_h);
// mp.setParameter(PARA_SCALE_DISP_WINDOW, request);
}
});
}Example 94
| Project: AndroidDemoProjects-master File: VideoPlayerActivity.java View source code |
protected void initViews() {
mSpinningProgressBar = (ProgressBar) findViewById(R.id.progress_spinner);
mVideoView = (VideoView) findViewById(R.id.video_view);
mVideoView.setOnCompletionListener(onCompletionListener);
mVideoView.setOnErrorListener(onErrorListener);
mVideoView.setOnPreparedListener(onPreparedListener);
if (mVideoView == null) {
throw new IllegalArgumentException("Layout must contain a video view with ID video_view");
}
mUri = Uri.parse(getIntent().getExtras().getString(EXTRA_VIDEO_URL));
mVideoView.setVideoURI(mUri);
}Example 95
| Project: BotLibre-master File: HttpChatAction.java View source code |
@Override
protected void onPostExecute(String xml) {
if (this.config.disconnect) {
return;
}
super.onPostExecute(xml);
if (this.exception != null) {
MainActivity.error(this.exception.getMessage(), this.exception, this.activity);
return;
}
try {
MainActivity.conversation = this.response.conversation;
final ChatActivity activity = (ChatActivity) this.activity;
ImageView imageView = (ImageView) activity.imageView;
final VideoView videoView = activity.videoView;
View videoLayout = activity.videoLayout;
if (MainActivity.sound && this.response.avatarActionAudio != null && this.response.avatarActionAudio.length() > 0) {
// Action audio
activity.playAudio(this.response.avatarActionAudio, false, true, true);
}
if (MainActivity.sound && this.response.avatarAudio != null && this.response.avatarAudio.length() > 0) {
// Background audio
if (!this.response.avatarAudio.equals(activity.currentAudio)) {
if (activity.audioPlayer != null) {
activity.audioPlayer.stop();
activity.audioPlayer.release();
}
activity.audioPlayer = activity.playAudio(this.response.avatarAudio, true, true, true);
}
} else if (activity.audioPlayer != null) {
activity.audioPlayer.stop();
activity.audioPlayer.release();
activity.audioPlayer = null;
}
if (!MainActivity.disableVideo && !activity.videoError && this.response.isVideo()) {
// Video avatar
if (imageView.getVisibility() != View.GONE || videoLayout.getVisibility() != View.GONE) {
if (imageView.getVisibility() == View.VISIBLE) {
imageView.setVisibility(View.GONE);
}
if (videoLayout.getVisibility() == View.GONE) {
videoLayout.setVisibility(View.VISIBLE);
}
}
if (this.response.avatarAction != null && this.response.avatarAction.length() > 0) {
// Action video
videoView.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.setLooping(false);
}
});
videoView.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
activity.resetVideoErrorListener();
videoView.setOnCompletionListener(null);
activity.cycleVideo(response);
activity.response(response);
}
});
videoView.setOnErrorListener(new OnErrorListener() {
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
activity.resetVideoErrorListener();
activity.cycleVideo(response);
activity.response(response);
return true;
}
});
activity.playVideo(this.response.avatarAction, false);
return;
} else {
activity.cycleVideo(this.response);
}
} else {
// Image avatar
if (imageView.getVisibility() != View.GONE || videoLayout.getVisibility() != View.GONE) {
if (imageView.getVisibility() == View.GONE) {
imageView.setVisibility(View.VISIBLE);
}
if (videoLayout.getVisibility() == View.VISIBLE) {
videoLayout.setVisibility(View.GONE);
}
}
if (this.response.isVideo()) {
HttpGetImageAction.fetchImage(this.activity, ((ChatActivity) this.activity).getAvatarIcon(this.response), imageView);
} else {
HttpGetImageAction.fetchImage(this.activity, this.response.avatar, imageView);
}
}
activity.response(this.response);
} catch (Exception error) {
this.exception = error;
MainActivity.error(this.exception.getMessage(), this.exception, this.activity);
return;
}
}Example 96
| Project: cumulus-master File: CumulusVideoPlayback.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/* Doing it the native way */
Intent parameters = getIntent();
if (parameters == null) {
//***************
setContentView(R.layout.fullvideo);
myVideoView = (VideoView) this.findViewById(R.id.myVideoView);
MediaController mc = new MediaController(this);
myVideoView.setMediaController(mc);
String ABCNews = "http://abclive.abcnews.com/i/abc_live4@136330/index_1200_av-b.m3u8";
String Brazil = "http://stream331.overseebrasil.com.br/live_previd_155/_definst_/live_previd_155/playlist.m3u8";
String NASA = "http://www.nasa.gov/multimedia/nasatv/NTV-Public-IPS.m3u8";
urlStream = ABCNews;
Log.d(TAG, "About to open " + urlStream.toString());
runOnUiThread(new Runnable() {
@Override
public void run() {
Log.d(TAG, "On UI Thread");
myVideoView.setVideoURI(Uri.parse(urlStream));
Log.d(TAG, "Now play");
myVideoView.start();
}
});
} else {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
getSupportActionBar().hide();
updateLauncherShortcut();
urlStream = parameters.getStringExtra(KEY_VIDEO_URL);
if (!urlStream.isEmpty()) {
mTvPlayer = new CumulusTvPlayer(this);
setContentView(R.layout.full_surfaceview);
SurfaceView sv = (SurfaceView) findViewById(R.id.surface);
mTvPlayer.setSurface(sv.getHolder().getSurface());
mTvPlayer.setVolume(1);
mTvPlayer.registerErrorListener(new CumulusTvPlayer.ErrorListener() {
@Override
public void onError(Exception error) {
Log.e(TAG, error.toString());
if (error instanceof MediaSourceFactory.NotMediaException) {
Log.d(TAG, "Cannot play the stream, try loading it as a website");
Toast.makeText(CumulusVideoPlayback.this, R.string.msg_open_web, Toast.LENGTH_SHORT).show();
CumulusWebPlayer wv = new CumulusWebPlayer(CumulusVideoPlayback.this, new CumulusWebPlayer.WebViewListener() {
@Override
public void onPageFinished() {
//Don't do anything
}
});
wv.load(urlStream);
setContentView(wv);
}
}
});
Log.d(TAG, "Start playing " + urlStream);
mTvPlayer.startPlaying(Uri.parse(urlStream));
mTvPlayer.play();
} else {
Toast.makeText(this, R.string.msg_no_url_found, Toast.LENGTH_SHORT).show();
finish();
}
}
}Example 97
| Project: CumulusTV-master File: CumulusVideoPlayback.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/* Doing it the native way */
Intent parameters = getIntent();
if (parameters == null) {
//***************
setContentView(R.layout.fullvideo);
myVideoView = (VideoView) this.findViewById(R.id.myVideoView);
MediaController mc = new MediaController(this);
myVideoView.setMediaController(mc);
String ABCNews = "http://abclive.abcnews.com/i/abc_live4@136330/index_1200_av-b.m3u8";
String Brazil = "http://stream331.overseebrasil.com.br/live_previd_155/_definst_/live_previd_155/playlist.m3u8";
String NASA = "http://www.nasa.gov/multimedia/nasatv/NTV-Public-IPS.m3u8";
urlStream = ABCNews;
Log.d(TAG, "About to open " + urlStream.toString());
runOnUiThread(new Runnable() {
@Override
public void run() {
Log.d(TAG, "On UI Thread");
myVideoView.setVideoURI(Uri.parse(urlStream));
Log.d(TAG, "Now play");
myVideoView.start();
}
});
} else {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
getSupportActionBar().hide();
updateLauncherShortcut();
urlStream = parameters.getStringExtra(KEY_VIDEO_URL);
if (!urlStream.isEmpty()) {
mTvPlayer = new CumulusTvPlayer(this);
setContentView(R.layout.full_surfaceview);
SurfaceView sv = (SurfaceView) findViewById(R.id.surface);
mTvPlayer.setSurface(sv.getHolder().getSurface());
mTvPlayer.setVolume(1);
mTvPlayer.registerErrorListener(new CumulusTvPlayer.ErrorListener() {
@Override
public void onError(Exception error) {
Log.e(TAG, error.toString());
if (error instanceof MediaSourceFactory.NotMediaException) {
Log.d(TAG, "Cannot play the stream, try loading it as a website");
Toast.makeText(CumulusVideoPlayback.this, R.string.msg_open_web, Toast.LENGTH_SHORT).show();
CumulusWebPlayer wv = new CumulusWebPlayer(CumulusVideoPlayback.this, new CumulusWebPlayer.WebViewListener() {
@Override
public void onPageFinished() {
//Don't do anything
}
});
wv.load(urlStream);
setContentView(wv);
}
}
});
Log.d(TAG, "Start playing " + urlStream);
mTvPlayer.startPlaying(Uri.parse(urlStream));
mTvPlayer.play();
} else {
Toast.makeText(this, R.string.msg_no_url_found, Toast.LENGTH_SHORT).show();
finish();
}
}
}Example 98
| Project: HomeSnap-master File: ScenarioActivity.java View source code |
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView textview = new TextView(this);
textview.setText("TODO: Scenario tab");
setContentView(textview);
try {
VideoView vv = new VideoView(this);
setContentView(vv);
// your URL here
String url = "http://192.168.1.238";
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setDataSource(url);
// might take long! (for buffering, etc)
mediaPlayer.prepare();
mediaPlayer.start();
} catch (Exception e) {
e.printStackTrace();
}
super.onCreate(savedInstanceState);
FrameLayout fl = new FrameLayout(this);
setContentView(fl);
SurfaceView mPreview = new SurfaceView(this);
fl.addView(mPreview);
// mPreview = (SurfaceView) findViewById(R.id.surface);
holder = mPreview.getHolder();
holder.addCallback(this);
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
extras = getIntent().getExtras();
}Example 99
| Project: image-chooser-library-master File: VideoChooserActivity.java View source code |
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video_chooser);
pbar = (ProgressBar) findViewById(R.id.pBar);
pbar.setVisibility(View.GONE);
imageViewThumb = (ImageView) findViewById(R.id.imageViewThumbnail);
imageViewThumbSmall = (ImageView) findViewById(R.id.imageViewThumbnailSmall);
videoView = (VideoView) findViewById(R.id.videoView);
setupAds();
checkForSharedVideo(getIntent());
}Example 100
| Project: mediatablet-master File: AudioVideoViewerActivity.java View source code |
@Override
protected void initialiseView(Bundle savedInstanceState) {
setContentView(R.layout.audio_video_viewer);
// guaranteed to exist and not to be null
File mediaFile = getCurrentMediaFile();
// can't play from private data directory, and can't use file descriptors like we do for narratives; instead,
// copy to temp before playback (this will take a *long* time)
File publicFile = mediaFile;
if (IOUtilities.isInternalPath(mediaFile.getAbsolutePath())) {
try {
if (MediaTablet.DIRECTORY_TEMP != null) {
publicFile = new File(MediaTablet.DIRECTORY_TEMP, mediaFile.getName());
IOUtilities.copyFile(mediaFile, publicFile);
IOUtilities.setFullyPublic(publicFile);
} else {
throw new IOException();
}
} catch (IOException e) {
UIUtilities.showToast(AudioVideoViewerActivity.this, R.string.error_loading_media);
finish();
return;
}
}
mControllerPrepared = false;
mMediaPrepared = false;
mVideoAudioPlayer = (VideoView) findViewById(R.id.media_audio_video);
mVideoAudioPlayer.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
if (mControllerPrepared) {
mMediaController.show(0);
}
}
});
mVideoAudioPlayer.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mMediaPrepared = true;
startPlayer();
}
});
mVideoAudioPlayer.setVideoURI(Uri.fromFile(publicFile));
mMediaController = new CustomMediaController(this);
RelativeLayout parentLayout = (RelativeLayout) findViewById(R.id.audio_video_view_parent);
RelativeLayout.LayoutParams controllerLayout = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
controllerLayout.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
parentLayout.addView(mMediaController, controllerLayout);
if (getCurrentMediaType() == MediaTabletProvider.TYPE_AUDIO) {
View audioBackground = findViewById(R.id.media_audio_image);
audioBackground.setVisibility(View.VISIBLE);
mMediaController.setAnchorView(audioBackground);
} else {
mMediaController.setAnchorView(findViewById(R.id.media_audio_video));
}
mControllerPrepared = true;
}Example 101
| Project: ohmagePhone-master File: VideoPrompt.java View source code |
@Override
public View inflateView(Context context, ViewGroup parent) {
super.inflateView(context, parent);
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.prompt_video, parent);
ImageButton button = (ImageButton) layout.findViewById(R.id.video_button);
VideoView video = (VideoView) layout.findViewById(R.id.video_view);
TextView instructions = (TextView) layout.findViewById(R.id.video_instructions);
instructions.setVisibility(View.VISIBLE);
video.setVisibility(View.GONE);
if (isPromptAnswered()) {
instructions.setVisibility(View.GONE);
video.setVisibility(View.VISIBLE);
video.setVideoPath(getMedia().getAbsolutePath());
MediaController ctlr = new PositionedMediaController(context, video);
video.requestFocus();
}
final Activity act = (Activity) context;
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE).putExtra(MediaStore.EXTRA_DURATION_LIMIT, mDuration);
act.startActivityForResult(intent, REQUEST_CODE);
}
});
return layout;
}