Skip to content

Commit

Permalink
1.8.8
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangmengxiong2 committed Dec 23, 2023
1 parent b851f27 commit 7f5e6a8
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 38 deletions.
34 changes: 16 additions & 18 deletions MXVideoLib/src/main/java/com/mx/video/MXVideo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -421,30 +421,28 @@ abstract class MXVideo @JvmOverloads constructor(

override fun stopPlay() {
val player = mxPlayer
scope.launch {
mxPlayer = null
isStopState = null
mxPlayer = null
isStopState = null

if (player != null) {
MXUtils.log("MXVideo: stopPlay()")
player.release()
}
if (player != null) {
MXUtils.log("MXVideo: stopPlay()")
scope.launch { player.release() }
}

viewSet.detachTextureView()
viewSet.detachTextureView()

if (PLAYING_VIDEO == this) {
PLAYING_VIDEO = null
}
if (PLAYING_VIDEO == this) {
PLAYING_VIDEO = null
}

sensorHelp.deleteListener(sensorListener)
sensorHelp.deleteListener(sensorListener)

if (config.source.get() == null) {
config.state.updateValue(MXState.IDLE)
} else {
config.state.updateValue(MXState.NORMAL)
}
config.loading.updateValue(false)
if (config.source.get() == null) {
config.state.set(MXState.IDLE)
} else {
config.state.set(MXState.NORMAL)
}
config.loading.set(false)
}

override fun pausePlay() {
Expand Down
17 changes: 5 additions & 12 deletions MXVideoLib/src/main/java/com/mx/video/utils/MXObservable.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,17 @@ class MXObservable<T>(defaultValue: T) {
private var _value: T = defaultValue

fun set(value: T) {
scope.launch { updateValue(value) }
if (value == _value) return
_value = value
scope.launch { notifyChangeSync() }
}

fun get() = _value

internal suspend fun updateValue(value: T) {
if (value == _value) return

val list = synchronized(lock) {
if (value == _value) return
_value = value
return@synchronized observerList.toMutableList()
}
if (!active.get()) return
if (list.isEmpty()) return
withContext(Dispatchers.Main) {
list.forEach { it.update(value) }
}
_value = value
notifyChangeSync()
}

internal fun notifyChange() {
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
最新版本:[![](https://jitpack.io/v/zhangmengxiong/MXVideo.svg)](https://jitpack.io/#zhangmengxiong/MXVideo)
```groovy
implementation 'com.github.zhangmengxiong:MXVideo:1.8.7'
implementation 'com.github.zhangmengxiong:MXVideo:1.8.8'
```

![Normal](https://gitee.com/zhangmengxiong/MXVideo/raw/master/imgs/1.png)
Expand Down
6 changes: 0 additions & 6 deletions app/src/main/assets/source.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@
"url": "http://video1.dgtle.com/backend%2F2020%2F3%2F0%2F%E6%88%91%E6%B2%A1%E6%9C%89%E7%BB%99%E4%B8%80%E5%8A%A08Pro%E5%81%9A%E8%AF%84%E6%B5%8B_%E5%8D%B4%E5%B8%A6%E7%9D%80%E5%AE%83%E6%BC%82%E6%B5%81.mp4_1080.mp4",
"img": "https://ts1.cn.mm.bing.net/th/id/R-C.2dfdaed9d3e59f8e20462202ec847723?rik=J06C3PjIKrv2gg&riu=http%3a%2f%2fup.deskcity.org%2fpic%2f202010%2fdt%2fqcyrevgybb31914.jpg&ehk=YrflT4NTtOIFDL7cWfvPYExD3esBhvVDT4en8CPqbx4%3d&risl=&pid=ImgRaw&r=0"
},
{
"type": "16:9",
"name": "精选视频3 - mkv",
"url": "http://video.cdn.aizys.com/zzx3.9g.mkv",
"img": "https://ts1.cn.mm.bing.net/th/id/R-C.b2ce2003596cd13b705d25facdd27860?rik=d4ivBEt4skiIwQ&riu=http%3a%2f%2fseopic.699pic.com%2fphoto%2f50064%2f4314.jpg_wh1200.jpg&ehk=ssMlV0RHlr3d5NxUoG%2faQrugcy2NB8BruRphOFxx1vI%3d&risl=&pid=ImgRaw&r=0"
},
{
"type": "16:9",
"name": "武漢抗疫視頻1",
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ ext {
minSdkVersion = 21

versionCode = 1
versionName = "1.8.7"
versionName = "1.8.8"
}

0 comments on commit 7f5e6a8

Please sign in to comment.