README.md 25.0 KB
Newer Older
S
readme  
shuyu 已提交
1
#### 基于[IJKPlayer](https://github.com/Bilibili/ijkplayer)的播放器,重构了[JieCaoVideoPlayer](https://github.com/lipangit/JieCaoVideoPlayer),调整了代码和优化了动画,添加了自定义功能。持续更新。
S
readme  
shuyu 已提交
2 3


S
readme  
shuyu 已提交
4 5 6 7 8 9
* **支持基本的拖动,声音、亮度调节。**
* **支持边播边缓存,使用了[AndroidVideoCache](https://github.com/danikula/AndroidVideoCache)。**
* **支持视频本身自带rotation的旋转。**
* **增加了重力旋转与手动旋转的同步支持。**
* **支持列表播放。**
* **直接添加控件为封面。**
S
shuyu 已提交
10
* **全屏和播放等的动画效果。**
S
readme  
shuyu 已提交
11 12 13
* **列表的全屏效果优化,多种配置模式。**
* **列表的小窗口播放,可拖动。**
* **网络视频加载速度。**
S
shuyu 已提交
14
* **锁定/解锁全屏点击功能。**
S
readme  
shuyu 已提交
15
* **6.0以上支持快播和慢播。**
S
readme  
shuyu 已提交
16
* **调整显示比例:默认、16:9、4:3。**
S
1.4.4  
shuyu 已提交
17
* **调整不同清晰度的支持。**
S
readme  
shuyu 已提交
18
* **支持IJKPlayer和EXOPlayer切换。**
S
shuyu 已提交
19
* **进度条小窗口预览(测试)。**
S
readme  
shuyu 已提交
20 21
* **Https支持。**
* **连续播放一个列表的视频。**
S
readme  
shuyu 已提交
22

S
readme  
shuyu 已提交
23
## QQ群,有兴趣的可以进来,无底线欢迎:174815284 。
S
shuyu 已提交
24

S
readme  
shuyu 已提交
25 26 27 28
### [*** 简书详解入口 *******************************************](http://www.jianshu.com/p/9fe377dd9750)
### [*** 问题集锦入口 *******************************************](https://github.com/CarGuo/GSYVideoPlayer/blob/master/QUESTION.md)
### [*** IJKPlayer问题入口 *************************************](http://www.jianshu.com/p/220b00d00deb) 
### [*** IJKPlayer编译自定义SO入口 ******************************](http://www.jianshu.com/p/bd289e25d272) 
S
readme  
shuyu 已提交
29

S
shuyu 已提交
30
[![](https://jitpack.io/v/CarGuo/GSYVideoPlayer.svg)](https://jitpack.io/#CarGuo/GSYVideoPlayer)
S
readme  
shuyu 已提交
31
[![Build Status](https://travis-ci.org/CarGuo/GSYVideoPlayer.svg?branch=master)](https://travis-ci.org/CarGuo/GSYVideoPlayer)
S
shuyu 已提交
32

S
readme  
shuyu 已提交
33
```
S
shuyu 已提交
34 35 36 37 38 39
allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}
S
readme  
shuyu 已提交
40
```
S
readme  
shuyu 已提交
41

S
readme  
shuyu 已提交
42
```
S
readme  
shuyu 已提交
43
dependencies {
S
shuyu 已提交
44
        compile 'com.github.CarGuo:GSYVideoPlayer:v1.4.9'
S
readme  
shuyu 已提交
45 46
}

S
readme  
shuyu 已提交
47
```
S
readme  
shuyu 已提交
48

S
readme  
shuyu 已提交
49
## 效果图下方版本说明,可以当做简单的wiki使用,效果可参考DEMO。
S
shuyu 已提交
50
 
S
shuyu 已提交
51
## 效果,录屏下的屏幕旋转和实际有些出入
S
readme  
shuyu 已提交
52

S
fix img  
shuyu 已提交
53 54 55
<img src="https://github.com/CarGuo/GSYVideoPlayer/blob/master/01.jpg" width="218px" height="120px"/>
<img src="https://github.com/CarGuo/GSYVideoPlayer/blob/master/02.jpg" width="120px" height="218px"/>
<img src="https://github.com/CarGuo/GSYVideoPlayer/blob/master/03.jpg" width="120px" height="218px"/>
S
1.1.5  
shuyu 已提交
56
<img src="https://github.com/CarGuo/GSYVideoPlayer/blob/master/04.jpg" width="120px" height="218px"/>
S
readme  
shuyu 已提交
57
 
S
1.1.5  
shuyu 已提交
58

S
readme  
shuyu 已提交
59
* ### 1、打开一个播放
S
shuyu 已提交
60
<img src="https://github.com/CarGuo/GSYVideoPlayer/blob/master/01.gif" width="240px" height="426px"/>
S
1.1.5  
shuyu 已提交
61

S
readme  
shuyu 已提交
62
* ### 2、列表/详情模式
S
readme  
shuyu 已提交
63
<img src="https://github.com/CarGuo/GSYVideoPlayer/blob/master/02.gif" width="240px" height="426px"/>
S
readme  
shuyu 已提交
64
<img src="https://github.com/CarGuo/GSYVideoPlayer/blob/master/05.gif" width="240px" height="426px"/>
S
shuyu 已提交
65 66
<img src="https://github.com/CarGuo/GSYVideoPlayer/blob/master/04.gif" width="240px" height="426px"/>

S
shuyu 已提交
67 68 69
* ### 3、进度条小窗口预览
<img src="https://github.com/CarGuo/GSYVideoPlayer/blob/master/07.gif" width="426px" height="240px"/>

S
readme  
shuyu 已提交
70 71

## 下方个版本说明,可以当做简单的wiki使用~,效果可参考DEMO。
S
shuyu 已提交
72

S
shuyu 已提交
73 74 75 76 77 78
### 1.4.9
* 增加了连续播放列表的支持 ListGSYVideoPlayer。
* 增加了列表播放的demo  DetailListPlayer。
* 减小了https版本的so的大小。


S
shuyu 已提交
79 80 81 82 83
### 1.4.8
* 锁定屏幕按键增加锁定屏幕旋转功能。
* 锁定屏幕按键增加回调接口。
* 修复了横屏的一个问题。

S
shuyu 已提交
84 85 86 87 88 89 90 91 92 93 94
### 1.4.7
* 修复直接横屏有闪动的问题。
* 修改了流量提示的接口。
* 增加了HTTPS支持。

```
/**
 * 是否需要显示流量提示,默认true
 */
public void setNeedShowWifiTip(boolean needShowWifiTip)
```
S
shuyu 已提交
95 96 97

### 1.4.6
* 修改了某些虚拟按键手机下,全屏后返回导致界面显示不正的问题。
S
shuyu 已提交
98
* 增加测试版CustomGSYVideoPlayer,实现滑动进度条预览效果(测试效果)。
S
shuyu 已提交
99 100
* 修改了出现除以0的的问题,全屏时候调整UI样式无效的情况。
* 注:CustomGSYVideoPlayer目前对已完全缓存的视频,或者本地文件支持好一些,对纯网络视频支持“较”差。
S
shuyu 已提交
101

S
shuyu 已提交
102 103
```
/**
S
shuyu 已提交
104
 * 如果是需要进度条预览的设置打开,默认关闭
S
shuyu 已提交
105 106 107
 */
public void setOpenPreView(boolean localFile)
```
S
shuyu 已提交
108

S
shuyu 已提交
109 110 111 112 113 114 115 116 117 118 119 120
### 1.4.5
* 支持切换IJKPlayer和EXOPlayer,不过EXOPlayer后台播放回到前台黑的问题除了seekto无解啊。

GSYVideoManager

```
/**
 * 设置了视频的播放类型
 * GSYVideoType IJKPLAYER = 0 or IJKEXOPLAYER = 1;
 */
public void setVideoType(Context context, int videoType)
```
S
1.4.4  
shuyu 已提交
121 122 123

### 1.4.4

S
readme  
shuyu 已提交
124
* 调整lib,DEMO中SampleVideo增加了调整清晰度的支持,DEMO借用了jjdxm_ijkplayer的URL。
S
readme  
shuyu 已提交
125
* 优化了Cache缓存和IJK 缓存之间的显示。
S
1.4.4  
shuyu 已提交
126 127


S
readme  
shuyu 已提交
128 129
### 1.4.3

S
1.4.3  
shuyu 已提交
130 131 132
* 增加了设置显示比例GSYVideoType。
* DEMO增加SampleVideo,在PlayActivity使用,调节显示比例效果。
* 增加了开启和关闭硬解码的接口GSYVideoType。
S
readme  
shuyu 已提交
133

S
1.4.3  
shuyu 已提交
134
GSYVideoType
S
readme  
shuyu 已提交
135 136 137 138 139
```
/**
 * 设置显示比例
 */
public static void setShowType(int type)
S
readme  
shuyu 已提交
140 141 142 143 144 145 146 147 148 149 150 151

/**
 * 使能硬解码,播放前设置
 */
public static void enableMediaCodec() {
    MEDIA_CODEC_FLAG = true;
}

/**
 * 关闭硬解码,播放前设置
 */
public static void disableMediaCodec()
S
readme  
shuyu 已提交
152 153
```

S
shuyu 已提交
154 155 156
### 1.4.2

* 修改了暂停画面在对旋转视频/竖屏播放时变形的问题。
S
shuyu 已提交
157
* 调整了亮度的灵敏度,优化了亮度调节。
S
shuyu 已提交
158

S
shuyu 已提交
159 160 161
### 1.4.1

* 增加了全屏锁开关,锁定后屏幕点击无效。
S
1.4.1  
shuyu 已提交
162 163
* 增加了全局暂停和播放,支援列表状态。
* 修正了亮度调节的问题。
S
shuyu 已提交
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188

StandardGSYVideoPlayer/ListVideoUtil

```
/**
 * 是否需要全屏锁定屏幕功能
 * 如果单独使用请设置setIfCurrentIsFullscreen为true
 */
public void setNeedLockFull(boolean needLoadFull)
```

GSYVideoManager

```
/**
 * 暂停播放
 */
public static void onPause()

/**
 * 恢复播放
 */
public static void onResume()
```

S
shuyu 已提交
189

S
readme  
shuyu 已提交
190
### 1.4.0 (3.8和3.9难产了)
191

S
readme  
shuyu 已提交
192
* 添加了lib封面对复用封面的支持和demo。
S
1.4.0  
shuyu 已提交
193 194 195
* 修复了缓冲进度条;
* 增加了recyclerViewDemo。
* update VideoCache,去除error out put log输出。
S
readme  
shuyu 已提交
196
* 修正了列表中隐藏虚拟键盘与actionbar的冲突。
S
1.3.6  
shuyu 已提交
197 198


S
1.4.1  
shuyu 已提交
199

S
readme  
shuyu 已提交
200 201 202 203
### 1.3.7 
* 优化了弹出框。
* 优化了暂停的时候(全屏/恢复全屏/退到)会是黑色的问题。
* 解决了暂停的时候拖动进度条问题。
S
1.3.6  
shuyu 已提交
204

S
readme  
shuyu 已提交
205 206 207 208 209 210 211 212 213 214

### 1.3.6 
* 区分了没有网络和没有wifi的提示。
* 更新了Demo detailPlayer直接旋转全屏。
* 返回正常的详情效果。


### 1.3.5 
* 增加了全屏隐藏虚拟按键。
* 修复了缓冲过程中加载动画就停止了。
S
1.3.5  
shuyu 已提交
215 216 217 218 219 220 221 222

```
/**
 * 全屏隐藏虚拟按键,默认打开
 */
public void setHideKey(boolean hideKey)
```

S
readme  
shuyu 已提交
223 224 225 226
### 1.3.4 
* 增加了清除默认缓存接口。
* 增加了播放偏移。
* 优化了拖动进度条或者缓存导致播放时间跳动的问题。
S
shuyu 已提交
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250

GSYVideoManager

```
/**
 * 删除默认所有缓存文件
 */
public static void clearAllDefaultCache(Context context)

/**
 * 删除url对应默认缓存文件
 */
public static void clearDefaultCache(Context context, String url)
```

GSYVideoPlayer

```

/**
 * 清除当前缓存
 */
public void clearCurrentCache()

S
1.3.4  
shuyu 已提交
251 252 253 254 255 256
/**
 * 从哪里开始播放
 * 目前有时候前几秒有跳动问题
 */
public void setSeekOnStart(int seekOnStart)

S
shuyu 已提交
257
```
S
1.3.2  
shuyu 已提交
258

S
readme  
shuyu 已提交
259 260 261 262
### 1.3.3 

* 优化了一些内存泄漏问题。
* 更新了demo。
S
1.2.9  
shuyu 已提交
263

S
readme  
shuyu 已提交
264
### 1.3.2 
S
1.3.1  
shuyu 已提交
265

S
readme  
shuyu 已提交
266
* 解决了因为兼容FragmentActivity导致actionbar隐藏失败问题。
S
1.3.1  
shuyu 已提交
267

S
readme  
shuyu 已提交
268 269 270 271 272
### 1.3.1 
* 更新了lastListener的判空问题。

### 1.3.0 
* 支持配置缓存路径,添加了ListVideoUtils的一些接口。
S
1.3.0  
shuyu 已提交
273 274 275 276 277

正常模式

```
//默认缓存路径方式
S
shuyu 已提交
278
holder.gsyVideoPlayer.setUp(url, true , "");
S
1.3.0  
shuyu 已提交
279 280 281 282 283 284 285 286 287

···

//一个列表的视频缓存路径相同
holder.gsyVideoPlayer.setUp(url, true, new File(FileUtils.getTestPath(), ""));

···

//如果一个列表里的缓存路径不同,需要用下方的方式
S
shuyu 已提交
288 289 290 291 292 293 294

//避免全屏返回的时候不可用了,只初始化不是当前位置的ui
if (playPosition < 0 || playPosition != position ||
        !GSYVideoManager.instance().getPlayTag().equals(ListNormalAdapter.TAG)) {
    holder.gsyVideoPlayer.initUIState();
}

S
1.3.0  
shuyu 已提交
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
//如果设置了点击封面可以播放,如果缓存列表路径不一致,还需要设置封面点击
holder.gsyVideoPlayer.setThumbPlay(true);

holder.gsyVideoPlayer.getStartButton().setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        //需要切换缓存路径的
        holder.gsyVideoPlayer.setUp(url, true, new File(FileUtils.getTestPath(), ""));
        holder.gsyVideoPlayer.startPlayLogic();
    }
});

holder.gsyVideoPlayer.getThumbImageViewLayout().setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        //需要切换缓存路径的
        holder.gsyVideoPlayer.setUp(url, true, new File(FileUtils.getTestPath(), ""));
        holder.gsyVideoPlayer.startPlayLogic();
    }
});
```
ListVideoUtils

```
public void setCachePath(File cachePath)

public void setObjects(Object[] objects)

public void setMapHeadData(Map<String, String> mapHeadData)

```


S
readme  
shuyu 已提交
328 329 330
### 1.2.9 

* 增加了下载速度的接口。
S
1.2.9  
shuyu 已提交
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348

```
/**
 * 网络速度
 * 注意,这里如果是开启了缓存,因为读取本地代理,缓存成功后还是存在速度的
 * 再打开已经缓存的本地文件,网络速度才会回0.因为是播放本地文件了
 */
public long getNetSpeed()

/**
 * 网络速度
 * 注意,这里如果是开启了缓存,因为读取本地代理,缓存成功后还是存在速度的
 * 再打开已经缓存的本地文件,网络速度才会回0.因为是播放本地文件了
 */
public String getNetSpeedText()

```

S
readme  
shuyu 已提交
349 350 351 352 353
### 1.2.8 

* 升级IJKPlayer到0.7.5。
* 增加了改变播放速度(0-2左右的速度),但只支持6.0以上。

S
1.2.8  
shuyu 已提交
354 355 356 357 358 359
```
/**
 * 播放速度
 */
public void setSpeed(float speed)
```
S
1.2.6  
shuyu 已提交
360

S
readme  
shuyu 已提交
361 362 363 364
### 1.2.7 
* 修改了循环播放的时候,重新播放不弹出控制UI。
* 修改了FragmentActivity的actionBar问题。

S
1.2.7  
shuyu 已提交
365

S
readme  
shuyu 已提交
366
### 1.2.6  
S
1.2.7  
shuyu 已提交
367

S
readme  
shuyu 已提交
368 369
* 修正了StandardGSYVideoPlayer的接口全屏回调问题。
* 增加了循环播放的接口。
S
1.2.6  
shuyu 已提交
370 371 372 373 374 375 376 377

```

public void setLooping(boolean looping)

```


S
readme  
shuyu 已提交
378
### 1.2.5  
S
1.2.5  
shuyu 已提交
379

S
readme  
shuyu 已提交
380 381 382 383
* 增加了新接口,支持直接横屏锁住界面。
* 关闭全屏动画,组合接口使用。

##### GSYVideoPlayer
S
1.2.5  
shuyu 已提交
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403

```
/**
 * 全屏动画
 *
 * @param showFullAnimation 是否使用全屏动画效果
 */
public void setShowFullAnimation(boolean showFullAnimation)

/**
 * 是否开启自动旋转
 */
public void setRotateViewAuto(boolean rotateViewAuto)

/**
 * 一全屏就锁屏横屏,默认false竖屏,可配合setRotateViewAuto使用
 */
public void setLockLand(boolean lockLand)
```

S
readme  
shuyu 已提交
404
##### ListVideoUtil
S
1.2.5  
shuyu 已提交
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435

```
/**
 * 是否自动旋转
 *
 * @param autoRotation 是否要支持重力旋转
 */
public void setAutoRotation(boolean autoRotation) {
    this.autoRotation = autoRotation;
}

/**
 * 是否全屏就马上横屏
 *
 * @param fullLandFrist 如果是,那么全屏的时候就会切换到横屏
 */
public void setFullLandFrist(boolean fullLandFrist) {
    this.fullLandFrist = fullLandFrist;
}

/**
 * 全屏动画
 *
 * @param showFullAnimation 是否使用全屏动画效果
 */
public void setShowFullAnimation(boolean showFullAnimation) {
    this.showFullAnimation = showFullAnimation;
}
```


S
readme  
shuyu 已提交
436 437 438
### 1.2.4 

* 兼容API修改至16,全屏动画兼容全API。
S
1.2.4  
shuyu 已提交
439 440
 

S
readme  
shuyu 已提交
441 442 443
### 1.2.3 

*增加了X86类型的依赖,个人可根据爱好在APP的build里面添加自己要的支持类型。
S
1.2.3  
shuyu 已提交
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459

arm64和-86_64的没有加入,如果需要自己添加即可,因为编译最低需要API21

```
android {
···
defaultConfig {
    ···
    ndk {
        //设置支持的SO库架构
        abiFilters 'armeabi', 'armeabi-v7a', 'x86'
    }
}

```

S
1.2.0  
shuyu 已提交
460

S
readme  
shuyu 已提交
461 462 463 464
### 1.2.2 

*开放了取时长和总时长的接口。
*增加了VideoAllCallBack的准备视频完成的回调onPrepared。
S
1.2.2  
shuyu 已提交
465 466 467 468 469 470 471 472 473 474 475 476

```

 listVideoUtil.getDuration()
 listVideoUtil.getCurrentPositionWhenPlaying();

 GSYVideoPlayer.getDuration()
 GSYVideoPlayer.getCurrentPositionWhenPlaying();

```


S
readme  
shuyu 已提交
477 478 479 480
### 1.2.1 

* 调整了小窗口回调拦截错误的情况。
* 增加了SampleListener在列表小窗口点击关闭的时候更新页面。
S
1.2.1  
shuyu 已提交
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502

```
//小窗口关闭被点击的时候回调处理回复页面
listVideoUtil.setVideoAllCallBack(new SampleListener(){
    @Override
    public void onQuitSmallWidget(String url, Object... objects) {
        super.onQuitSmallWidget(url, objects);
        //大于0说明有播放,//对应的播放列表TAG
        if (listVideoUtil.getPlayPosition() >= 0 && listVideoUtil.getPlayTAG().equals(ListVideoAdapter.TAG)) {
            //当前播放的位置
            int position = listVideoUtil.getPlayPosition();
            //不可视的是时候
            if ((position < firstVisibleItem || position > lastVisibleItem)) {
                //释放掉视频
                listVideoUtil.releaseVideoPlayer();
                listVideoAdapter.notifyDataSetChanged();
            }
        }
    }
});
```
 
S
readme  
shuyu 已提交
503 504 505
### 1.2.0 

* 去除了一些无用的依赖库,升级IJKPlayer到0.7.4。
S
1.2.5  
shuyu 已提交
506

S
readme  
shuyu 已提交
507
更容易导入,减少了无用的依赖情况,去除了import的时候需要配置gradle.properties的问题。
S
1.2.0  
shuyu 已提交
508

S
readme  
shuyu 已提交
509 510 511
### 1.1.9 

* 修正了回调接口VideoAllCallBack的回调结果,添加了注释,可以根据需要继承后覆写。
S
1.1.9  
shuyu 已提交
512 513

有全屏到非全屏,有小窗口到非小窗口,结束播放错误触摸等等的接口回调,增加了Debuger,可以使能或者关闭调试输出。
S
1.1.8  
shuyu 已提交
514

S
readme  
shuyu 已提交
515 516 517 518
### 1.1.8 

* 增加了如果Cache文件出现播放异常,就清除缓存文件的处理(预防)。
* StandardGSYVideoPlayer增加了一些UI配置接口。
S
1.1.8  
shuyu 已提交
519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549

```
/**
 * 底部进度条-弹出的
 */
public void setBottomShowProgressBarDrawable(Drawable drawable, Drawable thumb)


/**
 * 底部进度条-非弹出
 */
public void setBottomProgressBarDrawable(Drawable drawable)

/**
 * 声音进度条
 */
public void setDialogVolumeProgressBar(Drawable drawable)


/**
 * 中间进度条
 */
public void setDialogProgressBar(Drawable drawable)

/**
 * 中间进度条字体颜色
 */
public void setDialogProgressColor(int highLightColor, int normalColor)

```

S
readme  
shuyu 已提交
550 551 552
### 1.1.7 

* 增加了第二种列表 ListVideoUtil可拖动小窗口支持。
S
1.1.7  
shuyu 已提交
553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577

```
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
    int lastVisibleItem = firstVisibleItem + visibleItemCount;
    //大于0说明有播放,//对应的播放列表TAG
    if (listVideoUtil.getPlayPosition() >= 0 && listVideoUtil.getPlayTAG().equals(ListVideoAdapter.TAG)) {
        //当前播放的位置
        int position = listVideoUtil.getPlayPosition();
        //不可视的是时候
        if ((position < firstVisibleItem || position > lastVisibleItem)) {
            //如果是小窗口就不需要处理
            if (!listVideoUtil.isSmall()) {
                //小窗口
                int size = CommonUtil.dip2px(ListVideo2Activity.this, 150);
                listVideoUtil.showSmallVideo(new Point(size, size), false, true);
            }
        } else {
            if (listVideoUtil.isSmall()) {
                listVideoUtil.smallVideoToNormal();
            }
        }
    }
}
```
S
1.1.6  
shuyu 已提交
578

S
readme  
shuyu 已提交
579 580
### 1.1.6 
* 优化了第二种列表ListVideoUtil的全屏效果,和列表一的全屏效果一致,两种全屏效果增加是否打开关闭接口。
S
1.1.6  
shuyu 已提交
581 582 583 584 585 586 587 588 589 590

```
/**
 * 全屏动画
 *
 * @param showFullAnimation 是否使用全屏动画效果
 */
public void setShowFullAnimation(boolean showFullAnimation)
```

S
readme  
shuyu 已提交
591
### 1.1.5 
S
1.1.5  
shuyu 已提交
592

S
readme  
shuyu 已提交
593 594
* 优化了一些UI,增加了一些有趣的动画,比如播放按键。
* 推荐这个动画效果[ENViews](https://github.com/codeestX/ENViews)
S
readme  
shuyu 已提交
595
* 增加自定义继承模板**SampleExtendsPlayer**,个人建议直接拷贝**StandardGSYVideoPlayer**修改也行。
S
1.1.5  
shuyu 已提交
596

S
readme  
shuyu 已提交
597 598
### 1.1.4
* 优化了第一种列表的全屏动画,5.0以上展开和返回过渡顺畅,支持自动旋转的开启与关闭。
S
1.1.4  
shuyu 已提交
599
* 修改了全屏下的滑动接口不正常问题,全屏下自动变为滑动的,非全屏可以设置。
S
1.1.3  
shuyu 已提交
600

S
1.1.4  
shuyu 已提交
601 602 603 604 605 606 607 608 609
```
/**
 * 是否可以滑动界面改变进度,声音等
 */
public void setIsTouchWiget(boolean isTouchWiget)

```


S
readme  
shuyu 已提交
610 611
### 1.1.2
* 增加了TAG和position来实现第一种list列表(非ListVideoUtil模式的列表实现)的滑动错位问题。
S
shuyu 已提交
612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644

```

videoList.setOnScrollListener(new AbsListView.OnScrollListener() {
    @Override
    public void onScrollStateChanged(AbsListView view, int scrollState) {
    }

    @Override
    public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
        int lastVisibleItem = firstVisibleItem + visibleItemCount;
        //大于0说明有播放
        if (GSYVideoManager.instance().getPlayPosition() >= 0) {
            //当前播放的位置
            int position = GSYVideoManager.instance().getPlayPosition();
            //对应的播放列表TAG
            if (GSYVideoManager.instance().getPlayTag().equals(ListNormalAdapter.TAG)
                    && (position < firstVisibleItem || position > lastVisibleItem)) {
                //如果滑出去了上面和下面就是否,和今日头条一样
                GSYVideoPlayer.releaseAllVideos();
                listNormalAdapter.notifyDataSetChanged();
            }
        }
    }
});

····

holder.gsyVideoPlayer.setPlayTag(TAG);
holder.gsyVideoPlayer.setPlayPosition(position);

```

S
readme  
shuyu 已提交
645 646 647
### 1.1.1
* 增加了ListVideoUtil全屏是否显示横屏,全屏是否自动旋转。
* 增加了ListVideoUtils隐藏状态栏和title的接口。
S
shuyu 已提交
648

S
shuyu 已提交
649 650


S
readme  
shuyu 已提交
651
### GSYVideoPlayer 播放器控件,抽象类,继承后可以直接使用,参考 StandardGSYVideoPlayer
S
shuyu 已提交
652

S
readme  
shuyu 已提交
653
#### 记得调用销毁
S
shuyu 已提交
654
```
S
shuyu 已提交
655 656 657 658 659 660 661
@Override
 protected void onDestroy() {
     super.onDestroy();
     GSYVideoPlayer.releaseAllVideos();
}
```

S
readme  
shuyu 已提交
662
## StandardGSYVideoPlayer 标准的播放播放器,可参考demo中的playActivity
S
shuyu 已提交
663
```
S
shuyu 已提交
664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733

设置播放url,第二个参数表示需要边播边缓存
videoPlayer.setUp(url, true, "");

//增加封面
ImageView imageView = new ImageView(this);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setImageResource(R.mipmap.xxx1);
videoPlayer.setThumbImageView(imageView);

//增加title
videoPlayer.getTitleTextView().setVisibility(View.VISIBLE);
videoPlayer.getTitleTextView().setText("测试视频");

//设置返回键
videoPlayer.getBackButton().setVisibility(View.VISIBLE);

//设置旋转
orientationUtils = new OrientationUtils(this, videoPlayer);

//设置全屏按键功能
videoPlayer.getFullscreenButton().setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        orientationUtils.resolveByClick();
    }
});

//设置返回按键功能
videoPlayer.getBackButton().setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        onBackPressed();
    }
});

//在列表中使用的接口,详情请看Demo中的ListVideoActivity

/**
 * 利用window层播放全屏效果
 *
 * @param context
 * @param actionBar 是否有actionBar,有的话需要隐藏
 * @param statusBar 是否有状态bar,有的话需要隐藏
 */
public void startWindowFullscreen(final Context context, final boolean actionBar, final boolean statusBar)


/**
 * 退出window层播放全屏效果
 */
public void clearFullscreenLayout()

还有用于onBackPressed()的
/**
  * 退出全屏
  *
  */
public static boolean backFromWindowFull(Context context)

@Override
public void onBackPressed() {
    if (StandardGSYVideoPlayer.backFromWindowFull(this)) {
        return;
    }
    super.onBackPressed();
}
```

## OrientationUtils 重力旋转的工具类
S
shuyu 已提交
734
```
S
shuyu 已提交
735 736 737 738 739
//设置旋转
OrientationUtils orientationUtils = new OrientationUtils(Activity, videoPlayer);
```
## ListVideoUtil 列表模式支持支持滑出屏幕继续播放和全屏的工具类
与上面的StandardGSYVideoPlayer实现列表播放和全屏播放不大一样,ListVideoUtil只有一个StandardGSYVideoPlayer,使用外部container来是先全屏
S
shuyu 已提交
740
列表滑动不会影响到播放,具体可以查看demo里的ListVideoActivity和ListVideo2Activity.
S
shuyu 已提交
741
```
S
shuyu 已提交
742 743 744 745
listVideoUtil = new ListVideoUtil(Activity);
设置需要全屏显示的父类
listVideoUtil.setFullViewContainer(videoFullContainer);
.....
S
shuyu 已提交
746

S
shuyu 已提交
747
//对列表进行处理,传入每个item的位置,封面,TAG(如果有多个不同列表,用不同TAG区分),视频列表item的父容器,播放按键
S
shuyu 已提交
748 749 750 751 752 753 754 755 756 757 758 759
/**
 * 动态添加视频播放
 *
 * @param position  位置
 * @param imgView   封面
 * @param tag       TAG类型
 * @param container player的容器
 * @param playBtn   播放按键
 */
public void addVideoPlayer(final int position, View imgView, String tag,
                               ViewGroup container, View playBtn)

S
shuyu 已提交
760 761 762 763 764 765 766 767 768 769 770
holder.playerBtn.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        notifyDataSetChanged();
        //设置播放的位置和TAG
        listVideoUtil.setPlayPositionAndTag(position, TAG);
        final String url = "http://baobab.wdjcdn.com/14564977406580.mp4";
        //开始播放
        listVideoUtil.startPlay(url);
    }
});
S
readme  
shuyu 已提交
771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802


/**
 * 是否自动旋转
 *
 * @param autoRotation 是否要支持重力旋转
 */
public void setAutoRotation(boolean autoRotation)


/**
 * 是否全屏就马上横屏
 *
 * @param fullLandFrist 如果是,那么全屏的时候就会切换到横屏
 */
public void setFullLandFrist(boolean fullLandFrist)

/**
 * 是否隐藏statusBar
 *
 * @param hideStatusBar true的话会隐藏statusBar,在退出全屏的时候会回复显示
 */
public void setHideStatusBar(boolean hideStatusBar)

/**
 * 是否隐藏actionBar
 *
 * @param hideActionBar true的话会隐藏actionbar,在退出全屏的会回复时候显示
 */
public void setHideActionBar(boolean hideActionBar)


S
shuyu 已提交
803
```
S
shuyu 已提交
804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939

### SampleExtendsPlayer 自定义继承模板,可以参考 StandardGSYVideoPlayer

```

/**
 * 必须继承,你可以随意布局,但是id必须一致,还有不能少了哟
 */
@Override
public int getLayoutId() {
    //// TODO: 2016/11/18 返回你的布局
    return R.layout.video_layout_standard;
}

/**
 * 必须继承,根据你的状态实现不同的逻辑效果
 */
@Override
protected void setStateAndUi(int state) {
    super.setStateAndUi(state);
    switch (mCurrentState) {
        case CURRENT_STATE_NORMAL://播放UI初始化
            break;
        case CURRENT_STATE_PREPAREING://播放loading
            break;
        case CURRENT_STATE_PLAYING://播放ing
            break;
        case CURRENT_STATE_PAUSE://播放暂停
            break;
        case CURRENT_STATE_ERROR://播放错误
            break;
        case CURRENT_STATE_AUTO_COMPLETE://播放完成
            break;
        case CURRENT_STATE_PLAYING_BUFFERING_START://buffering
            break;
    }
}


/**
 * 继承后可以实现你自定义的UI配置
 */
@Override
protected void init(Context context) {
    super.init(context);
    //// TODO: 2016/11/18 你自定义的UI配置
}

/**
 * 继承后可以实现你自定义的UI
 */
@Override
public boolean setUp(String url, boolean cacheWithPlay, Object... objects) {
    super.setUp(url, cacheWithPlay, objects);
    //// TODO: 2016/11/18 你自定义的设置播放属性播放时候的UI配置
    return false;
}

@Override
public boolean onTouch(View v, MotionEvent event) {
    //// TODO: 2016/11/18 补充你的触摸逻辑 ,比如你在这一页自定义的哪些UI
    return super.onTouch(v, event);
}

@Override
public void onClick(View v) {
    super.onClick(v);
    //// TODO: 2016/11/18 补充你的点击逻辑 ,比如你在这一页自定义的哪些UI
}

@Override
public void showWifiDialog() {
    super.showWifiDialog();
    //// TODO: 2016/11/18 wifi状态的显示逻辑
}


@Override
public void startPlayLogic() {
    //// TODO: 2016/11/18 播放开始的逻辑
}

@Override
protected void setProgressAndTime(int progress, int secProgress, int currentTime, int totalTime) {
    super.setProgressAndTime(progress, secProgress, currentTime, totalTime);
    //// TODO: 2016/11/18 播放进度
}

@Override
protected void resetProgressAndTime() {
    super.resetProgressAndTime();
    //// TODO: 2016/11/18 播放进度重置
}

@Override
protected void showProgressDialog(float deltaX, String seekTime, int seekTimePosition, String totalTime, int totalTimeDuration) {
    super.showProgressDialog(deltaX, seekTime, seekTimePosition, totalTime, totalTimeDuration);
    //// TODO: 2016/11/18 显示快进dialog
}

@Override
protected void dismissProgressDialog() {
    super.dismissProgressDialog();
    //// TODO: 2016/11/18 关闭快进dialog
}

@Override
protected void showVolumeDialog(float deltaY, int volumePercent) {
    super.showVolumeDialog(deltaY, volumePercent);
    //// TODO: 2016/11/18 显示声音选择
}

@Override
protected void dismissVolumeDialog() {
    super.dismissVolumeDialog();
    //// TODO: 2016/11/18 关闭声音选择
}

@Override
protected void showBrightnessDialog(float percent) {
    super.showBrightnessDialog(percent);
    //// TODO: 2016/11/18 显示亮度选择
}

@Override
protected void dismissBrightnessDialog() {
    super.dismissVolumeDialog();
    //// TODO: 2016/11/18 关闭亮度选择
}

@Override
public void onBackFullscreen() {
    //// TODO: 2016/11/18 退出全屏逻辑
}

```
S
readme  
shuyu 已提交
940 941 942
 
## 混淆
 
S
shuyu 已提交
943

S
shuyu 已提交
944 945 946
```
-keep class tv.danmaku.ijk.** { *; }
-dontwarn tv.danmaku.ijk.**
947 948
-keep class com.shuyu.gsyvideoplayer.** { *; }
-dontwarn com.shuyu.gsyvideoplayer.**
S
todo  
shuyu 已提交
949
```