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;
    }

    }
  • 相关阅读:
    JAVA中线程池启动定时任务
    JAVA线程池的创建
    JAVA多线程售票问题
    设计模式之一 ---单例模式
    JAVAWeb使用POI做导出Excel
    ThreadLocal实现线程范围内共享
    线程的互斥与同步通信
    Spring-task-timer定时器
    万年历---java版
    linux sed 批量替换字符串
  • 原文地址:https://www.cnblogs.com/huihuizhang/p/6099230.html
Copyright © 2011-2022 走看看