V1.0.3(4)处理崩溃问题
This commit is contained in:
parent
7ee19d8635
commit
164dbd9495
@ -24,8 +24,8 @@ android {
|
|||||||
applicationId = "com.various.funny.sounds.audio"
|
applicationId = "com.various.funny.sounds.audio"
|
||||||
minSdk = 23
|
minSdk = 23
|
||||||
targetSdk = 34
|
targetSdk = 34
|
||||||
versionCode = 3
|
versionCode = 4
|
||||||
versionName = "1.0.2"
|
versionName = "1.0.3"
|
||||||
setProperty("archivesBaseName", "Various Funny Sounds_V" + versionName + "(${versionCode})_$timestamp")
|
setProperty("archivesBaseName", "Various Funny Sounds_V" + versionName + "(${versionCode})_$timestamp")
|
||||||
testInstrumentationRunner = "androidx.audio.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.audio.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.various.funny.sounds.audio.ui.activity
|
|||||||
|
|
||||||
import android.media.MediaPlayer
|
import android.media.MediaPlayer
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
@ -20,6 +21,8 @@ import com.various.funny.sounds.audio.max.MaxManager
|
|||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import java.io.File
|
||||||
|
import java.io.IOException
|
||||||
|
|
||||||
class PlayActivity : AppCompatActivity(), View.OnClickListener {
|
class PlayActivity : AppCompatActivity(), View.OnClickListener {
|
||||||
|
|
||||||
@ -67,6 +70,7 @@ class PlayActivity : AppCompatActivity(), View.OnClickListener {
|
|||||||
when (v) {
|
when (v) {
|
||||||
playBinding.imPlay -> {
|
playBinding.imPlay -> {
|
||||||
showAd()
|
showAd()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
playBinding.iconBack -> {
|
playBinding.iconBack -> {
|
||||||
@ -99,9 +103,22 @@ class PlayActivity : AppCompatActivity(), View.OnClickListener {
|
|||||||
mediaPlayer = MediaPlayer()
|
mediaPlayer = MediaPlayer()
|
||||||
mediaPlayer?.isLooping = true
|
mediaPlayer?.isLooping = true
|
||||||
newBeanChild.downloadUrl?.let {
|
newBeanChild.downloadUrl?.let {
|
||||||
|
val file = File(it)
|
||||||
|
if (file.exists()) {
|
||||||
|
mediaPlayer?.reset()
|
||||||
|
try {
|
||||||
mediaPlayer?.setDataSource(it)
|
mediaPlayer?.setDataSource(it)
|
||||||
mediaPlayer?.prepare()
|
mediaPlayer?.prepare()
|
||||||
isDownload = true
|
isDownload = true
|
||||||
|
} catch (ex: IOException) {
|
||||||
|
isDownload = false
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
isDownload = false
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -119,6 +136,7 @@ class PlayActivity : AppCompatActivity(), View.OnClickListener {
|
|||||||
} else {
|
} else {
|
||||||
playBinding.progressbar.isVisible = false
|
playBinding.progressbar.isVisible = false
|
||||||
file.absolutePath.let { path ->
|
file.absolutePath.let { path ->
|
||||||
|
mediaPlayer?.reset()
|
||||||
mediaPlayer?.setDataSource(path)
|
mediaPlayer?.setDataSource(path)
|
||||||
mediaPlayer?.prepare()
|
mediaPlayer?.prepare()
|
||||||
isDownload = true
|
isDownload = true
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user