本文整理汇总了Java中io.vov.vitamio.widget.VideoView类的典型用法代码示例。如果您正苦于以下问题:Java VideoView类的具体用法?Java VideoView怎么用?Java VideoView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VideoView类属于io.vov.vitamio.widget包,在下文中一共展示了VideoView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setVideoViewSize
import io.vov.vitamio.widget.VideoView; //导入依赖的package包/类
private void setVideoViewSize(int type) {
switch (type) {
case TYPE_NORMAL:
mIsFullScreen = false;
mFullScnBtn.setBackgroundResource(R.drawable.ib_fullscreen_selector);
// int width = Config.sDeviceWidth;
// int height = Config.sDeviceHeight;
int width = mScreenWidth;
int height = mScreenHeight;
if (mVideoWidth * height < width * mVideoHeight) {
//Log.i("@@@", "image too wide, correcting");
width = height * mVideoWidth / mVideoHeight;
} else if (mVideoWidth * height > width * mVideoHeight) {
//Log.i("@@@", "image too tall, correcting");
height = width * mVideoHeight / mVideoWidth;
}
mVideoPlayer.setVideoLayout(VideoView.VIDEO_LAYOUT_STRETCH, 0);
break;
case TYPE_FULL_SCREEN:
mIsFullScreen = true;
mVideoPlayer.setVideoLayout(VideoView.VIDEO_LAYOUT_SCALE, 0);
mFullScnBtn.setBackgroundResource(R.drawable.ib_not_fullscreen_selector);
break;
}
}
示例2: setupFullScreen
import io.vov.vitamio.widget.VideoView; //导入依赖的package包/类
/**
* 设置为全屏
*/
private void setupFullScreen() {
// 设置窗口模式
WindowManager.LayoutParams attrs = getWindow().getAttributes();
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
getWindow().setAttributes(attrs);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
// 获取屏幕尺寸
WindowManager manager = this.getWindowManager();
DisplayMetrics metrics = new DisplayMetrics();
manager.getDefaultDisplay().getMetrics(metrics);
// 设置Video布局尺寸
mVideoLayout.getLayoutParams().width = metrics.widthPixels;
mVideoLayout.getLayoutParams().height = metrics.heightPixels;
// 设置为全屏拉伸
mVideoView.setVideoLayout(VideoView.VIDEO_LAYOUT_SCALE, 0);
mIvIsFullscreen.setImageResource(R.mipmap.not_fullscreen);
mIsFullScreen = true;
}
示例3: setupUnFullScreen
import io.vov.vitamio.widget.VideoView; //导入依赖的package包/类
/**
* 设置为非全屏
*/
private void setupUnFullScreen() {
WindowManager.LayoutParams attrs = getWindow().getAttributes();
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setAttributes(attrs);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
float width = getResources().getDisplayMetrics().heightPixels;
float height = dp2px(200.f);
mVideoLayout.getLayoutParams().width = (int) width;
mVideoLayout.getLayoutParams().height = (int) height;
// 设置为全屏
mVideoView.setVideoLayout(VideoView.VIDEO_LAYOUT_SCALE, 0);
mIvIsFullscreen.setImageResource(R.mipmap.play_fullscreen);
mIsFullScreen = false;
}
示例4: mFindViewById
import io.vov.vitamio.widget.VideoView; //导入依赖的package包/类
private void mFindViewById() {
mCenterLayout = (CenterLayout) findViewById(R.id.vitamio_centerLayout);
mVideoView = (VideoView) findViewById(R.id.vitamio_videoview);
mLoadingView = findViewById(R.id.player_loading_layout);
mLoadingInfo = (TextView) findViewById(R.id.loading_text);
mVideoCenter = findViewById(R.id.player_center_iv);
mVideoBottom = findViewById(R.id.player_bottom_layout);
mVideoPlayPause = (ImageView) findViewById(R.id.player_play_iv);
mCurrentTime = (TextView) findViewById(R.id.player_current_time);
mTotalTime = (TextView) findViewById(R.id.player_total_time);
mSeekBar = (SeekBar) findViewById(R.id.player_seekbar);
mVideoShot = (ImageView) findViewById(R.id.video_shot);
mOrientationChange = (ImageView) findViewById(R.id.orientation_change);
mVideoTop = findViewById(R.id.player_top_bar);
mBack = findViewById(R.id.player_back);
mName = (TextView) findViewById(R.id.player_name);
mDLNA = findViewById(R.id.dlna_devices);
mDigitalClock = (DigitalClock) findViewById(R.id.clock);
mBatteryView = (BatteryView) findViewById(R.id.battery_view);
}
示例5: changeLayout
import io.vov.vitamio.widget.VideoView; //导入依赖的package包/类
public void changeLayout(View view) {
mVideoLayout++;
if (mVideoLayout == 4) {
mVideoLayout = 0;
}
switch (mVideoLayout) {
case 0:
mVideoLayout = VideoView.VIDEO_LAYOUT_ORIGIN;
view.setBackgroundResource(R.drawable.mediacontroller_sreen_size_100);
break;
case 1:
mVideoLayout = VideoView.VIDEO_LAYOUT_SCALE;
view.setBackgroundResource(R.drawable.mediacontroller_screen_fit);
break;
case 2:
mVideoLayout = VideoView.VIDEO_LAYOUT_STRETCH;
view.setBackgroundResource(R.drawable.mediacontroller_screen_size);
break;
case 3:
mVideoLayout = VideoView.VIDEO_LAYOUT_ZOOM;
view.setBackgroundResource(R.drawable.mediacontroller_sreen_size_crop);
break;
}
mVideoView.setVideoLayout(mVideoLayout, 0);
}
示例6: setStreamUrl
import io.vov.vitamio.widget.VideoView; //导入依赖的package包/类
@ReactProp(name = "streamUrl")
public void setStreamUrl(VideoView view, @Nullable String streamUrl) {
if (!LibsChecker.checkVitamioLibs(mActivity))
return;
view.setVideoPath(streamUrl);
view.setMediaController(new MediaController(mContext));
view.requestFocus();
view.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
// optional need Vitamio 4.0
mediaPlayer.setPlaybackSpeed(1.0f);
}
});
}
示例7: initPlay
import io.vov.vitamio.widget.VideoView; //导入依赖的package包/类
public void initPlay() {
mVideoView = (VideoView) findViewById(R.id.surface_view);
if (!isVideoPlayerOK) return;
// videoPath = FileUtils.getFileRootPath() + "/" + projectSlug + Config.VideosFolder + "/" + resourceSlug + ".mp4";
if (!(videoPath == null || videoPath.equals(""))) {
mVideoView.setVideoURI(Uri.parse(videoPath));
}
// Log.w(TAG, videoPath);
mVideoView.requestFocus();
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
// optional need Vitamio 4.0
Log.i(TAG, "onPrepared");
mediaPlayer.setPlaybackSpeed(1.0f);
mVideoView.addTimedTextSource(FileUtils.getFileRootPath() + "/" + projectSlug + Config.SourceFolder + "/" + resourceSlug + ".srt");
mVideoView.setOnTimedTextListener(TranslateActivity.this);
mVideoView.setTimedTextShown(true);
}
});
}
示例8: initView
import io.vov.vitamio.widget.VideoView; //导入依赖的package包/类
@Override
public void initView() {
this.mLoadinglinearlayout = (LinearLayout) findViewById(R.id.loading_LinearLayout);
this.mLoadingtv = (TextView) findViewById(R.id.loading_tv);
this.mLoadingImg = (ImageView) findViewById(R.id.loading_image);
this.mVideoView = (VideoView) findViewById(R.id.surface_view);
getDataFromIntent();
initTanMuViews();
initVideoSettings();
}
示例9: toggleVideoLayout
import io.vov.vitamio.widget.VideoView; //导入依赖的package包/类
/**
* 切换视频布局
*/
private void toggleVideoLayout() {
currentVideoLayout++;
if (currentVideoLayout > VideoView.VIDEO_LAYOUT_ZOOM) {
currentVideoLayout = VideoView.VIDEO_LAYOUT_ORIGIN;
}
mVideoView.setVideoLayout(currentVideoLayout, 0);
}
示例10: PlayerGesture
import io.vov.vitamio.widget.VideoView; //导入依赖的package包/类
public PlayerGesture(Activity activity, VideoView videoView, RelativeLayout rootView) {
mVideoView = videoView;
setScreenWidth(activity);
// 添加音量,亮度设置展示View,VideoView 的父布局必须是 RelativeLayout
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
DensityUtil.dip2px(activity, 60), DensityUtil.dip2px(activity, 60));
lp.addRule(RelativeLayout.CENTER_IN_PARENT);
mLV = new LightnessVolumeView(activity);
mLV.setLayoutParams(lp);
mLV.setActivity(activity);
mLV.setBackgroundResource(R.drawable.loading_bg);
mLV.setGravity(Gravity.CENTER);
mLV.setVisibility(View.GONE);
rootView.addView(mLV);
RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
lp2.addRule(RelativeLayout.CENTER_IN_PARENT);
mTime = new TextView(activity);
mTime.setLayoutParams(lp2);
mTime.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
mTime.setTextColor(Color.parseColor("#ffffff"));
mTime.setGravity(Gravity.CENTER);
mTime.setBackgroundResource(R.drawable.loading_bg);
mTime.setVisibility(View.GONE);
rootView.addView(mTime);
mTime.setPadding(20, 10, 20, 10);
mHandler = new Handler();
}
示例11: onCreate
import io.vov.vitamio.widget.VideoView; //导入依赖的package包/类
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
// ~~~ 获取播放地址和标题
Intent intent = getIntent();
mPath = intent.getStringExtra("path");
mTitle = intent.getStringExtra("title");
Log.i(">>>url play:", mPath);
// ~~~ 绑定控件
setContentView(R.layout.videoview);
mVideoView = (VideoView) findViewById(R.id.surface_view);
mVolumeBrightnessLayout = findViewById(R.id.operation_volume_brightness);
mOperationBg = (ImageView) findViewById(R.id.operation_bg);
mOperationPercent = (ImageView) findViewById(R.id.operation_percent);
mLoadingView = findViewById(R.id.video_loading);
// ~~~ 绑定事件
mVideoView.setOnCompletionListener(this);
mVideoView.setOnInfoListener(this);
// ~~~ 绑定数据
mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
mMaxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
if (mPath.startsWith("http:"))
mVideoView.setVideoURI(Uri.parse(mPath));
else
mVideoView.setVideoPath(mPath);
//设置显示名称
mMediaController = new MediaController(this);
mMediaController.setFileName(mTitle);
mVideoView.setMediaController(mMediaController);
mVideoView.requestFocus();
mGestureDetector = new GestureDetector(this, new MyGestureListener());
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
示例12: onDoubleTap
import io.vov.vitamio.widget.VideoView; //导入依赖的package包/类
/** 双击 */
@Override
public boolean onDoubleTap(MotionEvent e) {
if (mLayout == VideoView.VIDEO_LAYOUT_ZOOM)
mLayout = VideoView.VIDEO_LAYOUT_ORIGIN;
else
mLayout++;
if (mVideoView != null)
mVideoView.setVideoLayout(mLayout, 0);
return true;
}
示例13: initView
import io.vov.vitamio.widget.VideoView; //导入依赖的package包/类
@Override
public void initView() {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setHomeAsUpIndicator(R.drawable.icon_back);
}
mRl_video = (RelativeLayout) findViewById(R.id.rl_video);
// 显示缓冲百分比的TextView
percentTv = (TextView) findViewById(R.id.buffer_percent);
//显示下载网速的TextView
netSpeedTv = (TextView) findViewById(R.id.net_speed);
mVideoView = (VideoView) findViewById(R.id.vitamio);
video_cover = (ImageView) findViewById(R.id.video_cover);
mLoadingPage = (LoadingPage) findViewById(R.id.loading_page);
video_cover.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showVideoDialog();
}
});
}
示例14: onCreate
import io.vov.vitamio.widget.VideoView; //导入依赖的package包/类
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
if (!LibsChecker.checkVitamioLibs(this))
return;
setContentView(R.layout.videobuffer);
mVideoView = (VideoView) findViewById(R.id.buffer);
pb = (ProgressBar) findViewById(R.id.probar);
downloadRateView = (TextView) findViewById(R.id.download_rate);
loadRateView = (TextView) findViewById(R.id.load_rate);
if (path == "") {
// Tell the user to provide a media file URL/path.
Toast.makeText(
VideoViewBuffer.this,
"Please edit VideoBuffer Activity, and set path"
+ " variable to your media file URL/path", Toast.LENGTH_LONG).show();
return;
} else {
/*
* Alternatively,for streaming media you can use
* mVideoView.setVideoURI(Uri.parse(URLstring));
*/
uri = Uri.parse(path);
mVideoView.setVideoURI(uri);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
mVideoView.setOnInfoListener(this);
mVideoView.setOnBufferingUpdateListener(this);
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
// optional need Vitamio 4.0
mediaPlayer.setPlaybackSpeed(1.0f);
}
});
}
}
示例15: onCreate
import io.vov.vitamio.widget.VideoView; //导入依赖的package包/类
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
if (!LibsChecker.checkVitamioLibs(this))
return;
setContentView(R.layout.videoview);
mEditText = (EditText) findViewById(R.id.url);
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();
return;
} else {
/*
* Alternatively,for streaming media you can use
* mVideoView.setVideoURI(Uri.parse(URLstring));
*/
mVideoView.setVideoPath(path);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
// optional need Vitamio 4.0
mediaPlayer.setPlaybackSpeed(1.0f);
}
});
}
}