提交 e2dc9c80 编写于 作者: G guoshuyu

修改gl render的模式

上级 054ad9a5
package com.example.gsyvideoplayer; package com.example.gsyvideoplayer;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color; import android.graphics.Color;
import android.opengl.Matrix; import android.opengl.Matrix;
import android.os.Bundle; import android.os.Bundle;
...@@ -109,6 +110,7 @@ public class DetailFilterActivity extends GSYBaseActivityDetail { ...@@ -109,6 +110,7 @@ public class DetailFilterActivity extends GSYBaseActivityDetail {
private float deep = 0.8f; private float deep = 0.8f;
private String url = "https://res.exexm.com/cw_145225549855002"; private String url = "https://res.exexm.com/cw_145225549855002";
//private String url = "http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4";
private Timer timer = new Timer(); private Timer timer = new Timer();
...@@ -159,11 +161,11 @@ public class DetailFilterActivity extends GSYBaseActivityDetail { ...@@ -159,11 +161,11 @@ public class DetailFilterActivity extends GSYBaseActivityDetail {
//自定义render需要在播放器开始播放之前,播放过程中不允许切换render //自定义render需要在播放器开始播放之前,播放过程中不允许切换render
//水印图效果 //水印图效果
/*Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher); Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
mGSYVideoGLViewCustomRender = new GSYVideoGLViewCustomRender(); mGSYVideoGLViewCustomRender = new GSYVideoGLViewCustomRender();
mCustomBitmapIconEffect = new BitmapIconEffect(bitmap, dp2px(50), dp2px(50), 0.6f); mCustomBitmapIconEffect = new BitmapIconEffect(bitmap, dp2px(50), dp2px(50), 0.6f);
mGSYVideoGLViewCustomRender.setBitmapEffect(mCustomBitmapIconEffect); mGSYVideoGLViewCustomRender.setBitmapEffect(mCustomBitmapIconEffect);
detailPlayer.setCustomGLRenderer(mGSYVideoGLViewCustomRender);*/ detailPlayer.setCustomGLRenderer(mGSYVideoGLViewCustomRender);
//多窗口播放效果 //多窗口播放效果
//detailPlayer.setEffectFilter(new GammaEffect(0.8f)); //detailPlayer.setEffectFilter(new GammaEffect(0.8f));
......
...@@ -57,7 +57,7 @@ public class DetailPlayer extends AppCompatActivity { ...@@ -57,7 +57,7 @@ public class DetailPlayer extends AppCompatActivity {
//断网自动重新链接,url前接上ijkhttphook: //断网自动重新链接,url前接上ijkhttphook:
//String url = "ijkhttphook:https://res.exexm.com/cw_145225549855002"; //String url = "ijkhttphook:https://res.exexm.com/cw_145225549855002";
String url = "https://res.exexm.com/cw_145225549855002"; String url = "http://7xjmzj.com1.z0.glb.clouddn.com/20171026175005_JObCxCE2.mp4";
//String url = "http://103.233.191.21/riak/riak-bucket/6469ac502e813a4c1df7c99f364e70c1.mp4"; //String url = "http://103.233.191.21/riak/riak-bucket/6469ac502e813a4c1df7c99f364e70c1.mp4";
//String url = "http://7xjmzj.com1.z0.glb.clouddn.com/20171026175005_JObCxCE2.mp4"; //String url = "http://7xjmzj.com1.z0.glb.clouddn.com/20171026175005_JObCxCE2.mp4";
//String url = "https://media6.smartstudy.com/ae/07/3997/2/dest.m3u8"; //String url = "https://media6.smartstudy.com/ae/07/3997/2/dest.m3u8";
...@@ -110,7 +110,7 @@ public class DetailPlayer extends AppCompatActivity { ...@@ -110,7 +110,7 @@ public class DetailPlayer extends AppCompatActivity {
.setNeedLockFull(true) .setNeedLockFull(true)
.setSeekRatio(1) .setSeekRatio(1)
.setUrl(url) .setUrl(url)
.setCacheWithPlay(true) .setCacheWithPlay(false)
.setVideoTitle("测试视频") .setVideoTitle("测试视频")
.setStandardVideoAllCallBack(new SampleListener() { .setStandardVideoAllCallBack(new SampleListener() {
@Override @Override
......
...@@ -6,6 +6,7 @@ import android.graphics.SurfaceTexture; ...@@ -6,6 +6,7 @@ import android.graphics.SurfaceTexture;
import android.opengl.GLES20; import android.opengl.GLES20;
import android.opengl.GLException; import android.opengl.GLException;
import android.opengl.GLSurfaceView; import android.opengl.GLSurfaceView;
import android.opengl.Matrix;
import android.view.Surface; import android.view.Surface;
import com.shuyu.gsyvideoplayer.render.view.GSYVideoGLView; import com.shuyu.gsyvideoplayer.render.view.GSYVideoGLView;
...@@ -30,6 +31,18 @@ public abstract class GSYVideoGLViewBaseRender implements GLSurfaceView.Renderer ...@@ -30,6 +31,18 @@ public abstract class GSYVideoGLViewBaseRender implements GLSurfaceView.Renderer
protected GLSurfaceView mSurfaceView; protected GLSurfaceView mSurfaceView;
protected float[] mMVPMatrix = new float[16];
protected float[] mSTMatrix = new float[16];
protected int mCurrentViewWidth = 0;
protected int mCurrentViewHeight = 0;
protected int mCurrentVideoWidth = 0;
protected int mCurrentVideoHeight = 0;
public abstract void releaseAll(); public abstract void releaseAll();
...@@ -139,10 +152,15 @@ public abstract class GSYVideoGLViewBaseRender implements GLSurfaceView.Renderer ...@@ -139,10 +152,15 @@ public abstract class GSYVideoGLViewBaseRender implements GLSurfaceView.Renderer
this.mGSYSurfaceListener = onSurfaceListener; this.mGSYSurfaceListener = onSurfaceListener;
} }
public float[] getMVPMatrix() {
return mMVPMatrix;
}
/** /**
* 形变动画 * 形变动画
*/ */
public void setMVPMatrix(float[] MVPMatrix) { public void setMVPMatrix(float[] MVPMatrix) {
this.mMVPMatrix = MVPMatrix;
} }
/** /**
...@@ -159,11 +177,50 @@ public abstract class GSYVideoGLViewBaseRender implements GLSurfaceView.Renderer ...@@ -159,11 +177,50 @@ public abstract class GSYVideoGLViewBaseRender implements GLSurfaceView.Renderer
/** /**
* 设置滤镜效果 * 设置滤镜效果
*
* @param shaderEffect * @param shaderEffect
*/ */
public void setEffect(GSYVideoGLView.ShaderInterface shaderEffect) { public void setEffect(GSYVideoGLView.ShaderInterface shaderEffect) {
} }
public int getCurrentViewWidth() {
return mCurrentViewWidth;
}
public void setCurrentViewWidth(int currentViewWidth) {
this.mCurrentViewWidth = currentViewWidth;
}
public int getCurrentViewHeight() {
return mCurrentViewHeight;
}
public void setCurrentViewHeight(int currentViewHeight) {
this.mCurrentViewHeight = currentViewHeight;
}
public int getCurrentVideoWidth() {
return mCurrentVideoWidth;
}
public void setCurrentVideoWidth(int currentVideoWidth) {
this.mCurrentVideoWidth = currentVideoWidth;
}
public int getCurrentVideoHeight() {
return mCurrentVideoHeight;
}
public void setCurrentVideoHeight(int currentVideoHeight) {
this.mCurrentVideoHeight = currentVideoHeight;
}
public void initRenderSize() {
if (mCurrentViewWidth != 0 && mCurrentViewHeight != 0) {
Matrix.scaleM(mMVPMatrix, 0, (float) mCurrentViewWidth / mSurfaceView.getWidth(),
(float) mCurrentViewHeight / mSurfaceView.getHeight(), 1);
}
}
} }
...@@ -57,10 +57,6 @@ public class GSYVideoGLViewSimpleRender extends GSYVideoGLViewBaseRender { ...@@ -57,10 +57,6 @@ public class GSYVideoGLViewSimpleRender extends GSYVideoGLViewBaseRender {
+ " vTextureCoord = (uSTMatrix * aTextureCoord).xy;\n" + " vTextureCoord = (uSTMatrix * aTextureCoord).xy;\n"
+ "}\n"; + "}\n";
private float[] mMVPMatrix = new float[16];
private float[] mSTMatrix = new float[16];
private int mProgram; private int mProgram;
private int mTextureID[] = new int[2]; private int mTextureID[] = new int[2];
...@@ -266,10 +262,6 @@ public class GSYVideoGLViewSimpleRender extends GSYVideoGLViewBaseRender { ...@@ -266,10 +262,6 @@ public class GSYVideoGLViewSimpleRender extends GSYVideoGLViewBaseRender {
return maTextureHandle; return maTextureHandle;
} }
public float[] getMVPMatrix() {
return mMVPMatrix;
}
public float[] getSTMatrix() { public float[] getSTMatrix() {
return mSTMatrix; return mSTMatrix;
} }
...@@ -286,13 +278,6 @@ public class GSYVideoGLViewSimpleRender extends GSYVideoGLViewBaseRender { ...@@ -286,13 +278,6 @@ public class GSYVideoGLViewSimpleRender extends GSYVideoGLViewBaseRender {
return mEffect.getShader(mSurfaceView); return mEffect.getShader(mSurfaceView);
} }
/**
* 形变动画
*/
public void setMVPMatrix(float[] MVPMatrix) {
this.mMVPMatrix = MVPMatrix;
}
/** /**
* 打开截图 * 打开截图
*/ */
......
...@@ -75,6 +75,7 @@ public class GSYVideoGLView extends GLSurfaceView { ...@@ -75,6 +75,7 @@ public class GSYVideoGLView extends GLSurfaceView {
public void setCustomRenderer(GSYVideoGLViewBaseRender CustomRender) { public void setCustomRenderer(GSYVideoGLViewBaseRender CustomRender) {
this.mRenderer = CustomRender; this.mRenderer = CustomRender;
mRenderer.setSurfaceView(GSYVideoGLView.this); mRenderer.setSurfaceView(GSYVideoGLView.this);
initRenderMeasure();
} }
public void setGSYSurfaceListener(onGSYSurfaceListener mGSYSurfaceListener) { public void setGSYSurfaceListener(onGSYSurfaceListener mGSYSurfaceListener) {
...@@ -105,10 +106,36 @@ public class GSYVideoGLView extends GLSurfaceView { ...@@ -105,10 +106,36 @@ public class GSYVideoGLView extends GLSurfaceView {
this.mRenderer.setGSYVideoShotListener(listener, high); this.mRenderer.setGSYVideoShotListener(listener, high);
} }
@Override
public void onResume() {
super.onResume();
if(mRenderer != null) {
mRenderer.initRenderSize();
}
}
@Override @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
measureHelper.prepareMeasure(widthMeasureSpec, heightMeasureSpec, (int) getRotation()); measureHelper.prepareMeasure(widthMeasureSpec, heightMeasureSpec, (int) getRotation());
setMeasuredDimension(measureHelper.getMeasuredWidth(), measureHelper.getMeasuredHeight()); initRenderMeasure();
}
protected void initRenderMeasure() {
if (GSYVideoManager.instance().getMediaPlayer() != null) {
try {
int videoWidth = GSYVideoManager.instance().getCurrentVideoWidth();
int videoHeight = GSYVideoManager.instance().getCurrentVideoHeight();
if (this.mRenderer != null) {
this.mRenderer.setCurrentViewWidth(measureHelper.getMeasuredWidth());
this.mRenderer.setCurrentViewHeight(measureHelper.getMeasuredHeight());
this.mRenderer.setCurrentVideoWidth(videoWidth);
this.mRenderer.setCurrentVideoHeight(videoHeight);
}
} catch (Exception e) {
e.printStackTrace();
}
}
} }
public int getSizeH() { public int getSizeH() {
......
...@@ -466,7 +466,10 @@ public abstract class GSYVideoView extends GSYTextureRenderView implements GSYMe ...@@ -466,7 +466,10 @@ public abstract class GSYVideoView extends GSYTextureRenderView implements GSYMe
*/ */
protected void deleteCacheFileWhenError() { protected void deleteCacheFileWhenError() {
clearCurrentCache(); clearCurrentCache();
Debuger.printfError("Link Or mCache Error, Please Try Again" + mUrl); Debuger.printfError("Link Or mCache Error, Please Try Again " + mOriginUrl);
if (mCache) {
Debuger.printfError("mCache Link " + mUrl);
}
mUrl = mOriginUrl; mUrl = mOriginUrl;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册