本文整理汇总了Java中android.widget.VideoView.setVideoPath方法的典型用法代码示例。如果您正苦于以下问题:Java VideoView.setVideoPath方法的具体用法?Java VideoView.setVideoPath怎么用?Java VideoView.setVideoPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.VideoView
的用法示例。
在下文中一共展示了VideoView.setVideoPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.widget.VideoView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Find the video view by id so we can use it.
VideoView myVideo = (VideoView) findViewById(R.id.videoView);
// To set the path to the video. Sample.mp4 is in the "raw" folder.
// You can use http://online.path.to.your.video also.
myVideo.setVideoPath("android.resource://" + getPackageName() + "/" + R.raw.sample);
// To create the media controller (play, pause, etc.)
MediaController myController = new MediaController(this);
// To link the media controller to the video view.
myController.setAnchorView(myVideo);
// To link the video view to the media controller.
myVideo.setMediaController(myController);
// To autoplay on opening.
myVideo.start();
}
示例2: onCreate
import android.widget.VideoView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);//强制竖屏
final VideoView vv=new VideoView(this.getContext());
RelativeLayout rlmain=new RelativeLayout(this.getContext());
this.setContentView(vv);
TextView txt=new TextView(rlmain.getContext());
rlmain.addView(txt);
txt.setText("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
// rlmain.setBackgroundColor(Color.RED);
vv.setVideoPath("/sdcard/mwwyt.mpg");
vv.start();
vv.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
vv.start();
}
});
}
示例3: init
import android.widget.VideoView; //导入方法依赖的package包/类
private void init(String videoPath) {
setContentView(R.layout.activity_trim);
TextView duration = (TextView) findViewById(R.id.duration);
mPreview = (VideoView) findViewById(R.id.preview);
mShortVideoTrimmer = new PLShortVideoTrimmer(this, videoPath, Config.TRIM_FILE_PATH);
mMediaFile = new PLMediaFile(videoPath);
mSelectedEndMs = mDurationMs = mMediaFile.getDurationMs();
duration.setText("时长: " + formatTime(mDurationMs));
Log.i(TAG, "video duration: " + mDurationMs);
mVideoFrameCount = mMediaFile.getVideoFrameCount(false);
Log.i(TAG, "video frame count: " + mVideoFrameCount);
mPreview.setVideoPath(videoPath);
mPreview.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mediaPlayer) {
play();
}
});
initVideoFrameList();
}
示例4: 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();
}
}
示例5: go
import android.widget.VideoView; //导入方法依赖的package包/类
private void go() {
VideoView v=(VideoView)findViewById(R.id.videoView) ;
final ProgressBar p=(ProgressBar)findViewById(R.id.progressBar3);
v.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
p.setVisibility(View.GONE);
}
});
String s="https://firebasestorage.googleapis.com/v0/b/lifesaver-18f28.appspot.com/o/flood.mp4?alt=media&token=179d7e4e-7171-4a87-b1f8-b1fc3d976c60";
Uri uri=Uri.parse(s);
v.setVideoURI(uri);
v.setVideoPath(s);
v.requestFocus();
v.start();
}
示例6: go
import android.widget.VideoView; //导入方法依赖的package包/类
private void go() {
final ProgressBar p=(ProgressBar)findViewById(R.id.progressBar2);
VideoView v=(VideoView)findViewById(R.id.videoView2) ;
v.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
p.setVisibility(View.GONE);
}
});
String s="https://firebasestorage.googleapis.com/v0/b/lifesaver-18f28.appspot.com/o/earthquake.mp4?alt=media&token=98993371-823d-4b81-adc7-d9d87ec841a9";
Uri uri=Uri.parse(s);
v.setVideoURI(uri);
v.setVisibility(View.VISIBLE);
v.setVideoPath(s);
v.requestFocus();
v.start();
}
示例7: 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();
}
示例8: onCreate
import android.widget.VideoView; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video_play);
enableLayoutFullScreen();
mVideoView = (VideoView) findViewById(R.id.video_view);
playView = (ImageView) findViewById(R.id.play_view);
playView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
playView.setVisibility(View.GONE);
mVideoView.start();
}
});
String videoPath = getIntent().getStringExtra(KEY_VIDEO_PATH);
mVideoView.setVideoPath(videoPath);
mVideoView.start();
mVideoView.setOnCompletionListener(this);
}
示例9: 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);
}
示例10: 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();
}
示例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: loadVideoView
import android.widget.VideoView; //导入方法依赖的package包/类
/**
* Loads the video specified by mediaPath into the given VideoView.
*
* Note that if the mediaPath is an asset or an URL, the video must be copied
* to a temp file and then loaded from there. This could have performance
* implications.
*
* @param videoView the VideoView
* @param form the Form
* @param mediaPath the path to the media
*/
public static void loadVideoView(VideoView videoView, Form form, String mediaPath)
throws IOException {
MediaSource mediaSource = determineMediaSource(form, mediaPath);
switch (mediaSource) {
case ASSET:
case URL:
File tempFile = cacheMediaTempFile(form, mediaPath, mediaSource);
videoView.setVideoPath(tempFile.getAbsolutePath());
return;
case REPL_ASSET:
videoView.setVideoPath(replAssetPath(mediaPath));
return;
case SDCARD:
videoView.setVideoPath(mediaPath);
return;
case FILE_URL:
videoView.setVideoPath(fileUrlToFilePath(mediaPath));
return;
case CONTENT_URI:
videoView.setVideoURI(Uri.parse(mediaPath));
return;
case CONTACT_URI:
throw new IOException("Unable to load video for contact " + mediaPath + ".");
}
throw new IOException("Unable to load video " + mediaPath + ".");
}
示例13: initViews
import android.widget.VideoView; //导入方法依赖的package包/类
@Override
protected void initViews(Bundle savedInstanceState) {
videoView = (VideoView) findViewById(R.id.view_video);
android.widget.MediaController mediaController = new android.widget.MediaController(this);
videoView.setMediaController(mediaController);
File loopVideo = new File(LOOP_VIDEO_PATH);
if(loopVideo.exists()){
videoView.setVideoPath(LOOP_VIDEO_PATH);
videoView.start();
}else{
Toast.makeText(this, "vendor.mp4 没有找到!", Toast.LENGTH_SHORT).show();
}
}
示例14: init
import android.widget.VideoView; //导入方法依赖的package包/类
private void init() {
//Authentication and authorization of App and SDK
MemeLib.setAppClientID(getApplicationContext(), APP_ID, APP_SECRET);
memeLib = MemeLib.getInstance();
blinkLayout = (FrameLayout)findViewById(R.id.blink_layout);
blinkImage = (ImageView)findViewById(R.id.blink_image);
blinkView = (VideoView)findViewById(R.id.blink_view);
blinkView.setZOrderOnTop(true);
blinkView.setVideoPath("android.resource://" + this.getPackageName() + "/" + R.raw.blink);
blinkView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
mediaPlayer.seekTo(0);
}
});
bodyLayout = (FrameLayout)findViewById(R.id.body_layout);
bodyImage = (ImageView)findViewById(R.id.body_image);
statusLabel = (TextView)findViewById(R.id.status_label);
connectButton = (Button)findViewById(R.id.connect_button);
connectButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (memeLib.isConnected()) {
memeLib.disconnect();
} else {
Intent intent = new Intent(LiveViewActivity.this, ConnectActivity.class);
startActivity(intent);
}
}
});
changeViewStatus(memeLib.isConnected());
}
示例15: loadVideoView
import android.widget.VideoView; //导入方法依赖的package包/类
/**
* Loads the video specified by mediaPath into the given VideoView.
*
* Note that if the mediaPath is an asset or an URL, the video must be copied
* to a temp file and then loaded from there. This could have performance
* implications.
*
* @param videoView the VideoView
* @param form the Form
* @param mediaPath the path to the media
*/
public static void loadVideoView(VideoView videoView, FormService formservice, String mediaPath)
throws IOException {
MediaSource mediaSource = determineMediaSource(formservice, mediaPath);
switch (mediaSource) {
case ASSET:
case URL:
File tempFile = cacheMediaTempFile(formservice, mediaPath, mediaSource);
videoView.setVideoPath(tempFile.getAbsolutePath());
return;
case REPL_ASSET:
videoView.setVideoPath(replAssetPath(mediaPath));
return;
case SDCARD:
videoView.setVideoPath(mediaPath);
return;
case FILE_URL:
videoView.setVideoPath(fileUrlToFilePath(mediaPath));
return;
case CONTENT_URI:
videoView.setVideoURI(Uri.parse(mediaPath));
return;
case CONTACT_URI:
throw new IOException("Unable to load video for contact " + mediaPath + ".");
}
throw new IOException("Unable to load video " + mediaPath + ".");
}