Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
I
ImageVideoBanner
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jiangjiantao
ImageVideoBanner
Commits
3f2806c7
Commit
3f2806c7
authored
Feb 21, 2022
by
jiangjiantao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
视频背景动态模糊
parent
c2231a10
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
207 additions
and
30 deletions
+207
-30
build.gradle
imageVideoBanner/build.gradle
+1
-1
AndroidManifest.xml
imageVideoBanner/src/main/AndroidManifest.xml
+11
-11
MainActivity.java
...c/main/java/com/widget/imagevideobanner/MainActivity.java
+15
-14
CustomBlurEffect.java
.../com/widget/imagevideobanner/player/CustomBlurEffect.java
+92
-0
GSYVideoGLViewCustomRender4.java
.../imagevideobanner/player/GSYVideoGLViewCustomRender4.java
+54
-0
VideoSubView.java
...n/java/com/widget/imagevideobanner/view/VideoSubView.java
+34
-4
No files found.
imageVideoBanner/build.gradle
View file @
3f2806c7
apply
plugin:
'com.android.
library
'
apply
plugin:
'com.android.
application
'
android
{
compileSdkVersion
28
...
...
imageVideoBanner/src/main/AndroidManifest.xml
View file @
3f2806c7
...
...
@@ -15,18 +15,18 @@
android:supportsRtl=
"true"
android:theme=
"@style/AppTheme"
>
<!-- <activity-->
<!-- android:name=".MainActivity"-->
<!-- android:configChanges="orientation|keyboardHidden|screenSize|keyboard|navigation"-->
<!-- android:exported="true"-->
<!-- android:launchMode="singleTask"-->
<!-- android:screenOrientation="portrait">--
>
<!-- <intent-filter>--
>
<!-- <action android:name="android.intent.action.MAIN" />--
>
<!-- <category android:name="android.intent.category.LAUNCHER" />--
>
<!-- </intent-filter>--
>
<activity
android:name=
".MainActivity"
android:configChanges=
"orientation|keyboardHidden|screenSize|keyboard|navigation"
android:exported=
"true"
android:launchMode=
"singleTask"
android:screenOrientation=
"portrait"
>
<intent-filter
>
<action
android:name=
"android.intent.action.MAIN"
/
>
<category
android:name=
"android.intent.category.LAUNCHER"
/
>
</intent-filter
>
<!-- </activity>--
>
</activity
>
<activity
android:name=
".DetailActivity"
...
...
imageVideoBanner/src/main/java/com/widget/imagevideobanner/MainActivity.java
View file @
3f2806c7
...
...
@@ -27,28 +27,29 @@ public class MainActivity extends AppCompatActivity {
setContentView
(
R
.
layout
.
activity_main
);
banner
=
findViewById
(
R
.
id
.
banner
);
MediaBean
mediaBean
=
new
MediaBean
();
mediaBean
.
setUrl
(
"https://hh-oss-html.miyapay.com/hhops/picture/16045733014903c31992a674f.png"
);
mediaBean
.
setType
(
TYPE_IMAGE
);
list
.
add
(
mediaBean
);
MediaBean
mediaBean2
=
new
MediaBean
();
mediaBean2
.
setUrl
(
"https://hh-oss-html.miyapay.com/hhops/picture/1611112341654cffdd7b004bb.png"
);
mediaBean2
.
setType
(
TYPE_IMAGE
);
list
.
add
(
mediaBean2
);
//
MediaBean mediaBean = new MediaBean();
//
mediaBean.setUrl("https://hh-oss-html.miyapay.com/hhops/picture/16045733014903c31992a674f.png");
//
mediaBean.setType(TYPE_IMAGE);
//
list.add(mediaBean);
//
//
MediaBean mediaBean2 = new MediaBean();
//
mediaBean2.setUrl("https://hh-oss-html.miyapay.com/hhops/picture/1611112341654cffdd7b004bb.png");
//
mediaBean2.setType(TYPE_IMAGE);
//
list.add(mediaBean2);
// String basePath = "http://miya-hz.oss-cn-shanghai.aliyuncs.com/huihua-test/face-pay/archive/";
String
basePath
=
Environment
.
getExternalStorageDirectory
().
getPath
()+
"/"
;
MediaBean
mediaBean3
=
new
MediaBean
();
mediaBean3
.
setUrl
(
basePath
+
"
shu
.mp4"
);
mediaBean3
.
setUrl
(
basePath
+
"
1637567422388875
.mp4"
);
mediaBean3
.
setType
(
TYPE_VIDEO
);
mediaBean3
.
setLooping
(
true
);
list
.
add
(
mediaBean3
);
MediaBean
mediaBean4
=
new
MediaBean
();
mediaBean4
.
setUrl
(
basePath
+
"heng.mp4"
);
mediaBean4
.
setType
(
TYPE_VIDEO
);
list
.
add
(
mediaBean4
);
//
MediaBean mediaBean4 = new MediaBean();
//
mediaBean4.setUrl(basePath+"heng.mp4");
//
mediaBean4.setType(TYPE_VIDEO);
//
list.add(mediaBean4);
banner
.
bindData
(
list
);
...
...
imageVideoBanner/src/main/java/com/widget/imagevideobanner/player/CustomBlurEffect.java
0 → 100644
View file @
3f2806c7
package
com
.
widget
.
imagevideobanner
.
player
;
import
android.opengl.GLSurfaceView
;
import
com.shuyu.gsyvideoplayer.render.view.GSYVideoGLView
;
/**
* 简单模糊
* Created by guoshuyu on 2017/9/17.
*/
public
class
CustomBlurEffect
implements
GSYVideoGLView
.
ShaderInterface
{
private
int
countLevel
=
5
;
public
CustomBlurEffect
()
{
}
public
CustomBlurEffect
(
int
countLevel
)
{
this
.
countLevel
=
countLevel
;
}
public
void
setCountLevel
(
int
countLevel
)
{
this
.
countLevel
=
countLevel
;
}
@Override
public
String
getShader
(
GLSurfaceView
mGlSurfaceView
)
{
return
"#extension GL_OES_EGL_image_external : require\n"
+
"precision mediump float;\n"
+
"uniform samplerExternalOES sTexture; \n"
+
" \n"
+
"varying vec2 vTextureCoord;\n"
+
"const float barrelPower = 0.5; \n"
+
"const int num_iter = "
+
countLevel
+
"; \n"
+
"const float reci_num_iter_f = 1.0 / float(num_iter); \n"
+
" \n"
+
"vec2 barrelDistortion(vec2 coord, float amt) \n"
+
"{ \n"
+
" vec2 cc = coord - 0.5; \n"
+
" float dist = dot(cc, cc); \n"
+
" return coord + cc * dist * amt; \n"
+
"} \n"
+
" \n"
+
"float sat( float t ) \n"
+
"{ \n"
+
" return clamp( t, 0.0, 1.0 ); \n"
+
"} \n"
+
" \n"
+
"float linterp( float t ) { \n"
+
" return sat( 1.0 - abs( 2.0*t - 1.0 ) ); \n"
+
"} \n"
+
" \n"
+
"float remap( float t, float a, float b ) \n"
+
"{ \n"
+
" return sat( (t - a) / (b - a) ); \n"
+
"} \n"
+
" \n"
+
"vec3 spectrum_offset( float t ) \n"
+
"{ \n"
+
" vec3 ret; \n"
+
" float lo = step(t,0.5); \n"
+
" float hi = 1.0-lo; \n"
+
" float w = linterp( remap( t, 1.0/6.0, 5.0/6.0 ) ); \n"
+
" ret = vec3(lo,1.0,hi) * vec3(1.0-w, w, 1.0-w); \n"
+
" \n"
+
" return pow( ret, vec3(1.0/2.2) ); \n"
+
"} \n"
+
" \n"
+
"void main() \n"
+
"{ \n"
+
" vec2 uv=(gl_FragCoord.xy/vTextureCoord.xy); \n"
+
" \n"
+
" vec3 sumcol = vec3(0.0); \n"
+
" vec3 sumw = vec3(0.0); \n"
+
" for ( int i=0; i<num_iter;++i ) \n"
+
" { \n"
+
" float t = float(i) * reci_num_iter_f; \n"
+
" vec3 w = spectrum_offset( t );\n"
+
" sumw += w;\n"
+
" sumcol += w * texture2D( sTexture, barrelDistortion(vTextureCoord, barrelPower*t ) ).rgb; \n"
+
" }\n"
+
" gl_FragColor = vec4(sumcol.rgb / sumw, 1.0); \n"
+
"} "
;
}
}
imageVideoBanner/src/main/java/com/widget/imagevideobanner/player/GSYVideoGLViewCustomRender4.java
0 → 100644
View file @
3f2806c7
package
com
.
widget
.
imagevideobanner
.
player
;
import
android.opengl.GLES20
;
import
android.opengl.Matrix
;
import
com.shuyu.gsyvideoplayer.render.effect.NoEffect
;
import
com.shuyu.gsyvideoplayer.render.glrender.GSYVideoGLViewSimpleRender
;
import
javax.microedition.khronos.egl.EGLConfig
;
import
javax.microedition.khronos.opengles.GL10
;
/**
* 铺满的双重播放
* 配合高斯模糊,可以实现,高斯拉伸视频铺满背景,替换黑色,前台正常比例播放
* https://github.com/CarGuo/GSYVideoPlayer/issues/1252
*/
public
class
GSYVideoGLViewCustomRender4
extends
GSYVideoGLViewSimpleRender
{
private
int
mProgram
;
public
GSYVideoGLViewCustomRender4
()
{
super
();
}
@Override
public
void
onDrawFrame
(
GL10
glUnused
)
{
super
.
onDrawFrame
(
glUnused
);
GLES20
.
glUseProgram
(
mProgram
);
float
[]
transform
=
new
float
[
16
];
Matrix
.
setIdentityM
(
transform
,
0
);
Matrix
.
scaleM
(
transform
,
0
,
(
float
)
mCurrentViewWidth
/
mSurfaceView
.
getWidth
(),
(
float
)
mCurrentViewHeight
/
mSurfaceView
.
getHeight
(),
1
);
GLES20
.
glUniformMatrix4fv
(
getMuSTMatrixHandle
(),
1
,
false
,
mSTMatrix
,
0
);
GLES20
.
glUniformMatrix4fv
(
getMuMVPMatrixHandle
(),
1
,
false
,
transform
,
0
);
GLES20
.
glDrawArrays
(
GLES20
.
GL_TRIANGLE_STRIP
,
0
,
4
);
GLES20
.
glFinish
();
}
@Override
public
void
onSurfaceCreated
(
GL10
glUnused
,
EGLConfig
config
)
{
super
.
onSurfaceCreated
(
glUnused
,
config
);
mProgram
=
createProgram
(
getVertexShader
(),
new
NoEffect
().
getShader
(
mSurfaceView
));
}
@Override
public
void
initRenderSize
()
{
Matrix
.
scaleM
(
mMVPMatrix
,
0
,
1
f
,
1
f
,
1
);
}
}
imageVideoBanner/src/main/java/com/widget/imagevideobanner/view/VideoSubView.java
View file @
3f2806c7
...
...
@@ -2,18 +2,41 @@ package com.widget.imagevideobanner.view;
import
android.content.Context
;
import
android.support.annotation.NonNull
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.widget.FrameLayout
;
import
android.widget.ImageView
;
import
com.bumptech.glide.Glide
;
import
com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack
;
import
com.shuyu.gsyvideoplayer.video.GSYSampleADVideoPlayer
;
import
com.shuyu.gsyvideoplayer.render.effect.AutoFixEffect
;
import
com.shuyu.gsyvideoplayer.render.effect.BarrelBlurEffect
;
import
com.shuyu.gsyvideoplayer.render.effect.BlackAndWhiteEffect
;
import
com.shuyu.gsyvideoplayer.render.effect.BrightnessEffect
;
import
com.shuyu.gsyvideoplayer.render.effect.ContrastEffect
;
import
com.shuyu.gsyvideoplayer.render.effect.CrossProcessEffect
;
import
com.shuyu.gsyvideoplayer.render.effect.DocumentaryEffect
;
import
com.shuyu.gsyvideoplayer.render.effect.FillLightEffect
;
import
com.shuyu.gsyvideoplayer.render.effect.GammaEffect
;
import
com.shuyu.gsyvideoplayer.render.effect.GaussianBlurEffect
;
import
com.shuyu.gsyvideoplayer.render.effect.GrainEffect
;
import
com.shuyu.gsyvideoplayer.render.effect.HueEffect
;
import
com.shuyu.gsyvideoplayer.render.effect.InvertColorsEffect
;
import
com.shuyu.gsyvideoplayer.render.effect.LamoishEffect
;
import
com.shuyu.gsyvideoplayer.render.effect.NoEffect
;
import
com.shuyu.gsyvideoplayer.render.effect.OverlayEffect
;
import
com.shuyu.gsyvideoplayer.render.effect.PosterizeEffect
;
import
com.shuyu.gsyvideoplayer.render.effect.SampleBlurEffect
;
import
com.shuyu.gsyvideoplayer.render.effect.SaturationEffect
;
import
com.shuyu.gsyvideoplayer.render.effect.SepiaEffect
;
import
com.shuyu.gsyvideoplayer.render.effect.SharpnessEffect
;
import
com.shuyu.gsyvideoplayer.render.effect.TemperatureEffect
;
import
com.shuyu.gsyvideoplayer.render.effect.VignetteEffect
;
import
com.shuyu.gsyvideoplayer.render.view.GSYVideoGLView
;
import
com.shuyu.gsyvideoplayer.utils.GSYVideoType
;
import
com.widget.imagevideobanner.R
;
import
com.widget.imagevideobanner.bean.MediaBean
;
import
com.widget.imagevideobanner.log.BLogUtil
;
import
com.widget.imagevideobanner.player.CustomBlurEffect
;
import
com.widget.imagevideobanner.player.GSYVideoGLViewCustomRender4
;
import
com.widget.imagevideobanner.player.IPlayTarget
;
public
class
VideoSubView
extends
FrameLayout
implements
IPlayTarget
{
...
...
@@ -21,6 +44,8 @@ public class VideoSubView extends FrameLayout implements IPlayTarget {
private
OnActionFinishListener
mOnPageChangedListener
;
private
SampleCoverVideo
player
;
private
MediaBean
mediaBean
;
private
float
deep
=
0.8f
;
private
final
GSYSampleCallBack
sampleCallBack
=
new
GSYSampleCallBack
(){
@Override
...
...
@@ -48,6 +73,11 @@ public class VideoSubView extends FrameLayout implements IPlayTarget {
player
.
setVideoAllCallBack
(
sampleCallBack
);
player
.
loadCoverImage
(
mediaBean
.
getCover
(),
0
);
player
.
setUp
(
mediaBean
.
getUrl
(),
true
,
null
);
player
.
setEffectFilter
(
new
BarrelBlurEffect
());
// player.setEffectFilter(new GaussianBlurEffect(6.0f, GaussianBlurEffect.TYPEXY));
player
.
setCustomGLRenderer
(
new
GSYVideoGLViewCustomRender4
());
GSYVideoType
.
setRenderType
(
GSYVideoType
.
GLSURFACE
);
player
.
setGLRenderMode
(
GSYVideoGLView
.
MODE_RENDER_SIZE
);
player
.
setLooping
(
mediaBean
.
isLooping
());
BLogUtil
.
log
(
"设置视频轮播是否循环模式="
+
mediaBean
.
isLooping
());
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment