提交 15f9a3ba 编写于 作者: S shuyu

增加了全屏显示的支持 (2017-04-28)

上级 5a5f190d
......@@ -106,6 +106,7 @@ dependencies {
### 1.6.5(未发布)
* 修改了循环播放的UI问题
* 修改了本地文件或者已缓存文件,显示进度问题
* GSYVideoType增加SCREEN_TYPE_FULL类型,通过按照比例裁减放大视频,达到全屏
### 1.6.4(2017-04-20)
......
......@@ -3,6 +3,7 @@
### 1.6.5(未发布)
* 修改了循环播放的UI问题
* 修改了本地文件或者已缓存文件,显示进度问题
* GSYVideoType增加SCREEN_TYPE_FULL类型,通过按照比例裁减放大视频,达到全屏
### 1.6.4(2017-04-20)
* update ijk to 0.7.9 (增加了soundTouch,调速后声音变调问题得到解决)
......
......@@ -94,7 +94,7 @@ public class PlayActivity extends AppCompatActivity {
//设置旋转
orientationUtils = new OrientationUtils(this, videoPlayer);
//设置全屏按键功能
//设置全屏按键功能,这是使用的是选择屏幕,而不是全屏
videoPlayer.getFullscreenButton().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......
......@@ -20,6 +20,7 @@ import com.example.gsyvideoplayer.view.SwitchVideoTypeDialog;
import com.shuyu.gsyvideoplayer.GSYVideoManager;
import com.shuyu.gsyvideoplayer.GSYVideoPlayer;
import com.shuyu.gsyvideoplayer.utils.GSYVideoType;
import com.shuyu.gsyvideoplayer.video.GSYBaseVideoPlayer;
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;
import java.io.File;
......@@ -30,6 +31,9 @@ import java.util.TimerTask;
/**
* Created by shuyu on 2016/12/7.
* 注意
* 这个播放器的demo配置切换到全屏播放器
* 这只是单纯的作为全屏播放显示,如果需要做大小屏幕切换,请记得在这里耶设置上视频全屏的需要的自定义配置
*/
public class SampleVideo extends StandardGSYVideoPlayer {
......@@ -91,6 +95,12 @@ public class SampleVideo extends StandardGSYVideoPlayer {
if (mTextureView != null)
mTextureView.requestLayout();
} else if (mType == 2) {
mType = 3;
mMoreScale.setText("全屏");
GSYVideoType.setShowType(GSYVideoType.SCREEN_TYPE_FULL);
if (mTextureView != null)
mTextureView.requestLayout();
} else if (mType == 3) {
mType = 0;
mMoreScale.setText("默认比例");
GSYVideoType.setShowType(GSYVideoType.SCREEN_TYPE_DEFAULT);
......@@ -162,6 +172,16 @@ public class SampleVideo extends StandardGSYVideoPlayer {
return R.layout.sample_video;
}
@Override
public GSYBaseVideoPlayer startWindowFullscreen(Context context, boolean actionBar, boolean statusBar) {
SampleVideo sampleVideo = (SampleVideo) super.startWindowFullscreen(context, actionBar, statusBar);
//这个播放器的demo配置切换到全屏播放器
//这只是单纯的作为全屏播放显示,如果需要做大小屏幕切换,请记得在这里耶设置上视频全屏的需要的自定义配置
//可参考super中的实现
return sampleVideo;
}
/**
* 弹出切换清晰度
*/
......
package com.shuyu.gsyvideoplayer;
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;
......@@ -10,8 +11,14 @@ import com.shuyu.gsyvideoplayer.utils.GSYVideoType;
* Created by shuyu on 2016/12/6.
*/
@SuppressLint("AppCompatCustomView")
public class GSYImageCover extends ImageView {
private boolean fullView;
private int originW, originH;
public GSYImageCover(Context context, AttributeSet attrs) {
super(context, attrs);
}
......@@ -37,8 +44,11 @@ public class GSYImageCover extends ImageView {
int widthS = getDefaultSize(videoWidth, widthMeasureSpec);
int heightS = getDefaultSize(videoHeight, heightMeasureSpec);
///Debuger.printfError("******** video size " + getRotation() + " " + videoHeight + " *****1 " + videoWidth);
//Debuger.printfError("******** widget size " + widthS + " *****2 " + heightS);
if (originW == 0 || originH == 0) {
originW = widthS;
originH = heightS;
}
if (videoWidth > 0 && videoHeight > 0) {
int widthSpecMode = MeasureSpec.getMode(widthMeasureSpec);
......@@ -83,9 +93,8 @@ public class GSYImageCover extends ImageView {
// no size yet, just adopt the given spec sizes
}
//Debuger.printfError("******** rotate before " + width + " *****3 " + height);
if (getRotation() != 0 && getRotation() % 90 == 0 && Math.abs(getRotation()) != 180) {
boolean rotate = (getRotation() != 0 && getRotation() % 90 == 0 && Math.abs(getRotation()) != 180);
if (rotate) {
if (widthS < heightS) {
if (width > height) {
width = (int) (width * (float) widthS / height);
......@@ -104,7 +113,6 @@ public class GSYImageCover extends ImageView {
}
}
//Debuger.printfError("******** real size before " + width + " *****3 " + height);
//如果旋转后的高度大于宽度
if (width > height) {
//如果视频的旋转后,width(高度)大于控件高度,需要压缩下高度
......@@ -128,7 +136,6 @@ public class GSYImageCover extends ImageView {
}
}
//Debuger.printfError("******** real size " + width + " *****3 " + height);
//如果设置了比例
if (GSYVideoType.getShowType() == GSYVideoType.SCREEN_TYPE_16_9) {
if (height > width) {
......@@ -143,6 +150,50 @@ public class GSYImageCover extends ImageView {
height = width * 3 / 4;
}
}
fullView = (GSYVideoType.getShowType() == GSYVideoType.SCREEN_TYPE_FULL);
//上面会调整一变全屏,这里如果要全屏裁减,就整另外一边
if (fullView) {
if (rotate && getRotation() != 0) {
if (width > height) {
if (height < originW) {
width = (int) (width * ((float) originW / height));
height = originW;
} else if (width < originH) {
height = (int) (height * ((float) originH / width));
width = originH;
}
} else {
if (width < originH) {
height = (int) (height * ((float) originH / width));
width = originH;
} else if (height < originW) {
width = (int) (width * ((float) originW / height));
height = originW;
}
}
} else {
if (height > width) {
if (width < widthS) {
height = (int) (height * ((float) widthS / width));
width = widthS;
} else {
width = (int) (width * ((float) heightS / height));
height = heightS;
}
} else {
if (height < heightS) {
width = (int) (width * ((float) heightS / height));
height = heightS;
} else {
height = (int) (height * ((float) widthS / width));
width = widthS;
}
}
}
}
setMeasuredDimension(width, height);
}
......
......@@ -47,8 +47,6 @@ public class GSYTextureView extends TextureView {
originH = heightS;
}
///Debuger.printfError("******** video size " + getRotation() + " " + videoHeight + " *****1 " + videoWidth);
//Debuger.printfError("******** widget size " + widthS + " *****2 " + heightS);
if (videoWidth > 0 && videoHeight > 0) {
int widthSpecMode = MeasureSpec.getMode(widthMeasureSpec);
......@@ -93,7 +91,6 @@ public class GSYTextureView extends TextureView {
// no size yet, just adopt the given spec sizes
}
//Debuger.printfError("******** rotate before " + width + " *****3 " + height);
boolean rotate = (getRotation() != 0 && getRotation() % 90 == 0 && Math.abs(getRotation()) != 180);
if (rotate) {
if (widthS < heightS) {
......@@ -114,7 +111,6 @@ public class GSYTextureView extends TextureView {
}
}
//Debuger.printfError("******** real size before " + width + " *****3 " + height);
//如果旋转后的高度大于宽度
if (width > height) {
//如果视频的旋转后,width(高度)大于控件高度,需要压缩下高度
......@@ -138,7 +134,6 @@ public class GSYTextureView extends TextureView {
}
}
//Debuger.printfError("******** real size " + width + " *****3 " + height);
//如果设置了比例
if (GSYVideoType.getShowType() == GSYVideoType.SCREEN_TYPE_16_9) {
if (height > width) {
......@@ -154,8 +149,10 @@ public class GSYTextureView extends TextureView {
}
}
fullView = (GSYVideoType.getShowType() == GSYVideoType.SCREEN_TYPE_FULL);
//上面会调整一变全屏,这里如果要全屏裁减,就整另外一边
if (true) {
if (fullView) {
if (rotate && getRotation() != 0) {
if (width > height) {
if (height < originW) {
......@@ -209,12 +206,4 @@ public class GSYTextureView extends TextureView {
public int getSizeW() {
return sizeW;
}
public boolean isFullView() {
return fullView;
}
public void setFullView(boolean fullView) {
this.fullView = fullView;
}
}
\ No newline at end of file
......@@ -15,6 +15,9 @@ public class GSYVideoType {
//4:3
public final static int SCREEN_TYPE_4_3 = 2;
//全屏裁减显示
public final static int SCREEN_TYPE_FULL = 4;
public final static int IJKPLAYER = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册