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

    }
  • 相关阅读:
    替换Srun3000解决掉网问题
    了解Equals所发生的事情
    WPF自定义TextBox及ScrollViewer
    自制多类编码转换工具
    .NET4.5之自制多LRC转SRT小工具
    JAVA_list总结
    记一次线程Timer导致的线程安全问题修正
    JAVA_匿名内部类
    JAVA_map总结
    JAVA_闭包
  • 原文地址:https://www.cnblogs.com/huihuizhang/p/6099230.html
Copyright © 2011-2022 走看看