Skip to content

Commit

Permalink
修改了播放器全屏时的选择90度的时候,动画拉伸了的问题(2017-04-12)
Browse files Browse the repository at this point in the history
  • Loading branch information
CarGuo committed Apr 12, 2017
1 parent 8d75f38 commit a07fbff
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ protected void onCreate(Bundle savedInstanceState) {

private void init() {
String url = "http://baobab.wdjcdn.com/14564977406580.mp4";

//String url = "http://7xse1z.com1.z0.glb.clouddn.com/1491813192";
//需要路径的
//videoPlayer.setUp(url, true, new File(FileUtils.getPath()), "");

//借用了jjdxm_ijkplayer的URL
String source1 = "http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4";
String source1 = "http://111.198.24.133:83/yyy_login_server/pic/YB059284/97778276040859/1.mp4";
String name = "普通";
SwitchVideoModel switchVideoModel = new SwitchVideoModel(name, source1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public View getView(final int position, View convertView, ViewGroup parent) {

final String url = "http://baobab.wdjcdn.com/14564977406580.mp4";
//final String url = "http://7xse1z.com1.z0.glb.clouddn.com/1491813192";
//final String url = "http://111.198.24.133:83/yyy_login_server/pic/YB059284/97778276040859/1.mp4";

//默认缓存路径
holder.gsyVideoPlayer.setUp(url, true , null, "这是title");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,24 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
}
}

//如果旋转后的高度大于宽度
if (width > height) {
//如果视频的旋转后,width(高度)大于控件高度,需要压缩下高度
if (width > heightS) {
width = heightS;
height = (int) (height * (float) (width / heightS));
if (heightS < widthS) {
if (width > heightS) {
height = (int) (height * ((float) width / heightS));
width = heightS;
}
} else {
if (width > heightS) {
height = (int) (height / ((float) width / heightS));
width = heightS;
}
}
} else {
//如果旋转后的宽度大于高度
if (height > widthS) {
width = (int) (width * ((float) height / widthS));
height = widthS;
width = (int) (width * (float) (height / widthS));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthS = getDefaultSize(videoWidth, widthMeasureSpec);
int heightS = getDefaultSize(videoHeight, heightMeasureSpec);

//Debuger.printfError("******** video size " + getRotation() + " " + videoHeight + " *****1 " + videoWidth);
///Debuger.printfError("******** video size " + getRotation() + " " + videoHeight + " *****1 " + videoWidth);
//Debuger.printfError("******** widget size " + widthS + " *****2 " + heightS);
if (videoWidth > 0 && videoHeight > 0) {

Expand Down Expand Up @@ -86,7 +86,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

//Debuger.printfError("******** rotate before " + width + " *****3 " + height);

if (getRotation() != 0 && getRotation() % 90 == 0) {
if (getRotation() != 0 && getRotation() % 90 == 0 && Math.abs(getRotation()) != 180) {
if (widthS < heightS) {
if (width > height) {
width = (int) (width * (float) widthS / height);
Expand All @@ -105,18 +105,26 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
}
}

//Debuger.printfError("******** real size before " + width + " *****3 " + height);
//如果旋转后的高度大于宽度
if (width > height) {
//如果视频的旋转后,width(高度)大于控件高度,需要压缩下高度
if (width > heightS) {
width = heightS;
height = (int) (height * (float) (width / heightS));
if (heightS < widthS) {
if (width > heightS) {
height = (int) (height * ((float) width / heightS));
width = heightS;
}
} else {
if (width > heightS) {
height = (int) (height / ((float) width / heightS));
width = heightS;
}
}
} else {
//如果旋转后的宽度大于高度
if (height > widthS) {
width = (int) (width * ((float) height / widthS));
height = widthS;
width = (int) (width * (float) (height / widthS));
}
}
}
Expand Down

0 comments on commit a07fbff

Please sign in to comment.