zoukankan      html  css  js  c++  java
  • 视频 之自定义VideoView

    package com.lvshandian.partylive.view;

    import android.content.Context;
    import android.util.AttributeSet;
    import android.widget.VideoView;

    /**
    * Created by zhang on 2016/11/24.
    */

    public class FullScreenVideoView extends VideoView {
    private int videoWidth;
    private int videoHeight;

    public FullScreenVideoView(Context context) {
    super(context);
    }

    public FullScreenVideoView(Context context, AttributeSet attrs) {
    super(context, attrs);
    }

    public FullScreenVideoView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int width = getDefaultSize(videoWidth, widthMeasureSpec);
    int height = getDefaultSize(videoHeight, heightMeasureSpec);
    if (videoWidth > 0 && videoHeight > 0) {
    if (videoWidth * height > width * videoHeight) {
    height = width * videoHeight / videoWidth;
    } else if (videoWidth * height < width * videoHeight) {
    width = height * videoWidth / videoHeight;
    }
    }
    setMeasuredDimension(width, height);
    }

    public int getVideoWidth() {
    return videoWidth;
    }

    public void setVideoWidth(int videoWidth) {
    this.videoWidth = videoWidth;
    }

    public int getVideoHeight() {
    return videoHeight;
    }

    public void setVideoHeight(int videoHeight) {
    this.videoHeight = videoHeight;
    }

    }
  • 相关阅读:
    js_sl 分享
    js_sl 延迟菜单
    jszs 历史管理
    jszs 对象引用
    jszs 快速排序
    jszs 枚举算法
    dom cookie记录用户名
    dom 拖拽回放
    dom div重合提示
    dom 输入文字模拟滚动
  • 原文地址:https://www.cnblogs.com/huihuizhang/p/6099230.html
Copyright © 2011-2022 走看看