本文整理汇总了Java中android.widget.VideoView.setMediaController方法的典型用法代码示例。如果您正苦于以下问题:Java VideoView.setMediaController方法的具体用法?Java VideoView.setMediaController怎么用?Java VideoView.setMediaController使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.VideoView
的用法示例。
在下文中一共展示了VideoView.setMediaController方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.widget.VideoView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.video_full);
videofull=(VideoView)findViewById(R.id.videofull);
videofull.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.video));
videofull.setMediaController(new MediaController(VideoFull.this));
videofull.start();
videofull.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.setLooping(true);
}
});
videofull.requestFocus();
}
示例2: onCreate
import android.widget.VideoView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Find the video view by id so we can use it.
VideoView myVideo = (VideoView) findViewById(R.id.videoView);
// To set the path to the video. Sample.mp4 is in the "raw" folder.
// You can use http://online.path.to.your.video also.
myVideo.setVideoPath("android.resource://" + getPackageName() + "/" + R.raw.sample);
// To create the media controller (play, pause, etc.)
MediaController myController = new MediaController(this);
// To link the media controller to the video view.
myController.setAnchorView(myVideo);
// To link the video view to the media controller.
myVideo.setMediaController(myController);
// To autoplay on opening.
myVideo.start();
}
示例3: onCreate
import android.widget.VideoView; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
VideoView videoView = new VideoView(this);
setContentView(videoView);
videoView.setMediaController(new MediaController(this));
videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
Toast.makeText( VideoPlayerActivity.this, "播放完成了", Toast.LENGTH_SHORT).show();
}
});
String videoPath = getIntent().getStringExtra("videoPath");
try {
videoView.setVideoPath(videoPath);
videoView.start();
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(VideoPlayerActivity.this, "视频不存在", Toast.LENGTH_SHORT).show();
}
}
示例4: onCreate
import android.widget.VideoView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_player);
mVideoPath = getIntent().getStringExtra("videoPath");
if (!TextUtils.isEmpty(mVideoPath)) {
new RecentMediaStorage(this).saveUrlAsync(mVideoPath);
}
videoView = (VideoView) findViewById(R.id.view_video);
android.widget.MediaController mediaController = new android.widget.MediaController(this);
videoView.setMediaController(mediaController);
videoView.setVideoPath(mVideoPath);
videoView.start();
}
示例5: onCreate
import android.widget.VideoView; //导入方法依赖的package包/类
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video);
// Load the appropriate URL in the VideoView.
final String youtubeId = getIntent().getStringExtra(Keys.YOUTUBE_ID);
final String videoUrl = UrlBuilder.forYoutubeId(youtubeId);
final VideoView videoView = (VideoView) findViewById(R.id.video_view);
videoView.setVideoPath(videoUrl);
videoView.start();
// Add a MediaController, which gives us play/pause, etc.
final MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
videoView.setMediaController(mediaController);
}
示例6: onCreate
import android.widget.VideoView; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
PreferencesState.getInstance().loadsLanguageInActivity();
setContentView(R.layout.video_activity);
//Displays a video file.
MediaController mediaController = new MediaController(VideoActivity.this);
mVideoView = (VideoView)findViewById(R.id.videoview);
String videoPathParam = getIntent().getStringExtra(VIDEO_PATH_PARAM);
mVideoView.setVideoPath(videoPathParam);
mVideoView.setMediaController(mediaController);
mediaController.setAnchorView(mVideoView);
mVideoView.requestFocus();
if (savedInstanceState != null) {
mVideoView.seekTo(savedInstanceState.getInt("video",0));
}
mVideoView.start();
}
示例7: VideoPlayer
import android.widget.VideoView; //导入方法依赖的package包/类
/**
* Creates a new VideoPlayer component.
*
* @param container
*/
public VideoPlayer(ComponentContainer container) {
super(container);
videoView = new VideoView(container.$context());
videoView.setMediaController(new MediaController(container.$context()));
videoView.setOnCompletionListener(this);
videoView.setOnErrorListener(this);
// add the component to the designated container
container.$add(this);
// set a default size
container.setChildWidth(this, ComponentConstants.VIDEOPLAYER_PREFERRED_WIDTH);
container.setChildHeight(this, ComponentConstants.VIDEOPLAYER_PREFERRED_HEIGHT);
container.$form().registerForOnInitialize(this);
sourcePath = "";
}
示例8: onCreateView
import android.widget.VideoView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View myView = inflater.inflate(R.layout.fragment_main, container, false);
mVideoView = (VideoView)myView.findViewById(R.id.videoView1);
mVideoView.setMediaController(new MediaController(getActivity()));
//setup the button take a video.
Button btn1 = (Button)myView.findViewById(R.id.button1);
btn1.setOnClickListener( new View.OnClickListener(){
@Override
public void onClick(View v) {
//create an intent to have the default video record take a video.
Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
if (takeVideoIntent.resolveActivity(getActivity().getPackageManager()) != null) {
startActivityForResult(takeVideoIntent, MainActivity.REQUEST_VIDEO_CAPTURE);
}
}
});
return myView;
}
示例9: onCreate
import android.widget.VideoView; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//Get the ViewView
vv = (VideoView) this.findViewById( R.id.videoView);
//add media controls to it.
vv.setMediaController(new MediaController(this));
//Setup where the file to play is
//on the SDcard in the root directory. Not you need permissions to read the external storage.
//Uri videoUri = Uri.parse(Environment.getExternalStorageDirectory().getPath() + "/the-empire.3gp");
//Log.v("path",Environment.getExternalStorageDirectory().getPath() );
//via the web. Note you need Internet permissions.
Uri videoUri = Uri.parse("http://www.cs.uwyo.edu/~seker/courses/4730/example/the-empire.3gp");
vv.setVideoURI(videoUri);
//play the video
vv.start();
}
示例10: onCreateView
import android.widget.VideoView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View myView = inflater.inflate(R.layout.fragment_main, container, false);
//Get the ViewView
vv = (VideoView) myView.findViewById( R.id.videoView);
//add media controls to it. //note, in a fragment, this dies... don't know why.
// in both frag and activity these are are wrong: getApplicationContext() and getBaseContext()
//It's not context, actually needs the activity, so it can display the controls to the screen.
vv.setMediaController(new MediaController(getActivity()));
//Setup where the file to play is
//on the SDcard in the root directory. Now you need permissions to read the external storage.
//Uri videoUri = Uri.parse(Environment.getExternalStorageDirectory().getPath() + "/the-empire.3gp");
//Log.v("path",Environment.getExternalStorageDirectory().getPath() );
//via the web. Note you need Internet permissions.
Uri videoUri = Uri.parse("http://www.cs.uwyo.edu/~seker/courses/4730/example/the-empire.3gp");
vv.setVideoURI(videoUri);
//play the video
vv.start();
return myView;
}
示例11: onCreate
import android.widget.VideoView; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
PreferencesState.getInstance().initalizateActivityDependencies();
setContentView(R.layout.video_activity);
//Displays a video file.
MediaController mediaController = new MediaController(VideoActivity.this);
mVideoView = (VideoView) findViewById(R.id.videoview);
String videoPathParam = getIntent().getStringExtra(VIDEO_PATH_PARAM);
File file = new File(videoPathParam);
if (file.exists()) {
mVideoView.setVideoPath(videoPathParam);
} else {
mVideoView.setVideoURI(FileIOUtils.getRawUri(videoPathParam));
}
mVideoView.setMediaController(mediaController);
mediaController.setAnchorView(mVideoView);
mVideoView.requestFocus();
if (savedInstanceState != null) {
mVideoView.seekTo(savedInstanceState.getInt("video", 0));
}
mVideoView.start();
}
示例12: onCreate
import android.widget.VideoView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_live_stuff);
myVideoView = (VideoView)this.findViewById(R.id.videoView);
MediaController mc = new MediaController(this);
myVideoView.setMediaController(mc);
urlStream = "http://10.5.5.9:8080/live/amba.m3u8";
runOnUiThread(new Runnable() {
@Override
public void run() {
myVideoView.setVideoURI(Uri.parse(urlStream));
myVideoView.start();
}
});
}
示例13: onCreate
import android.widget.VideoView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video_bmx);
String uriPath = "android.resource://mx.ambmultimedia.brillamexico/raw/bmx_video";
Uri uri = Uri.parse(uriPath);
video = (VideoView) findViewById(R.id.videoView);
video.setVideoURI(uri);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(video);
video.setMediaController(mediaController);
video.start();
video.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer vmp) {
Intent intent = new Intent(VideoBMX.this, LoginStep1.class);
startActivity(intent);
}
});
}
示例14: onCreate
import android.widget.VideoView; //导入方法依赖的package包/类
@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();
}
示例15: onCreate
import android.widget.VideoView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
VideoView v = (VideoView) findViewById(R.id.videoView);
// v.setVideoPath("/sdcard/video.mp4");
v.setVideoURI(Uri.parse(String.format(
"android.resource://%s/%s",
getPackageName(),
R.raw.video
)));
v.setMediaController(new MediaController(this));
v.requestFocus();
v.start();
}