diff --git a/HISTORY.md b/HISTORY.md index bf30c15b..b8e4ea66 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,6 +1,6 @@ ## 更新日志 -### v2.0.8 +### v2.0.9 * 修复部分设备闪退的问题 * 修复设置页可能显示不全的问题 diff --git a/app/build.gradle b/app/build.gradle index 14ccedbb..7166c444 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -105,7 +105,11 @@ dependencies { implementation "androidx.media3:media3-ui:$media3_version" // For media playback using ExoPlayer - implementation "androidx.media3:media3-exoplayer:$media3_version" + implementation ("com.google.guava:guava:31.1-android") + implementation ("androidx.media3:media3-common:$media3_version") { + exclude group: 'com.google.common', module: 'guava' + } + implementation ("androidx.media3:media3-exoplayer:$media3_version") // For HLS playback support with ExoPlayer implementation "androidx.media3:media3-exoplayer-hls:$media3_version" @@ -133,9 +137,12 @@ dependencies { implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.2" implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.0-RC") - implementation 'com.google.android.exoplayer:exoplayer-ui:2.13.3' - implementation 'com.google.android.exoplayer:exoplayer-core:2.13.3' - implementation 'com.google.android.exoplayer:exoplayer-hls:2.13.3' - implementation 'javax.annotation:javax.annotation-api:1.3.2' +} + +configurations.configureEach { + resolutionStrategy { + force 'com.google.code.gson:gson:2.10.1' + force 'com.google.guava:guava:31.1-android' + } } \ No newline at end of file diff --git a/app/src/main/java/com/lizongying/mytv/PlayerFragment.kt b/app/src/main/java/com/lizongying/mytv/PlayerFragment.kt index bf3a228a..b2a56a3d 100644 --- a/app/src/main/java/com/lizongying/mytv/PlayerFragment.kt +++ b/app/src/main/java/com/lizongying/mytv/PlayerFragment.kt @@ -3,8 +3,6 @@ package com.lizongying.mytv import android.os.Bundle import android.util.Log import android.view.LayoutInflater -import android.view.SurfaceHolder -import android.view.SurfaceView import android.view.View import android.view.ViewGroup import android.view.ViewTreeObserver @@ -15,41 +13,26 @@ import androidx.media3.common.PlaybackException import androidx.media3.common.Player import androidx.media3.common.VideoSize import androidx.media3.common.util.UnstableApi -import androidx.media3.exoplayer.DefaultRenderersFactory import androidx.media3.exoplayer.ExoPlayer import androidx.media3.ui.PlayerView -import com.google.android.exoplayer2.SimpleExoPlayer import com.lizongying.mytv.databinding.PlayerBinding import com.lizongying.mytv.models.TVViewModel -class PlayerFragment : Fragment(), SurfaceHolder.Callback { +class PlayerFragment : Fragment() { private var _binding: PlayerBinding? = null private var playerView: PlayerView? = null private var tvViewModel: TVViewModel? = null private val aspectRatio = 16f / 9f - - private lateinit var surfaceView: SurfaceView - private lateinit var surfaceHolder: SurfaceHolder - private var exoPlayer: SimpleExoPlayer? = null - override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { _binding = PlayerBinding.inflate(inflater, container, false) - if (Utils.isTmallDevice()) { - _binding!!.playerView.visibility = View.GONE - surfaceView = _binding!!.surfaceView - surfaceHolder = surfaceView.holder - surfaceHolder.addCallback(this) - } else { - _binding!!.surfaceView.visibility = View.GONE - playerView = _binding!!.playerView - } + playerView = _binding!!.playerView playerView?.viewTreeObserver?.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener { @@ -111,10 +94,6 @@ class PlayerFragment : Fragment(), SurfaceHolder.Callback { setMediaItem(MediaItem.fromUri(tvViewModel.getVideoUrlCurrent())) prepare() } - exoPlayer?.run { - setMediaItem(com.google.android.exoplayer2.MediaItem.fromUri(tvViewModel.getVideoUrlCurrent())) - prepare() - } } override fun onStart() { @@ -125,11 +104,6 @@ class PlayerFragment : Fragment(), SurfaceHolder.Callback { playerView!!.player?.prepare() playerView!!.player?.play() } - if (exoPlayer?.isPlaying == false) { - Log.i(TAG, "replay") - exoPlayer?.prepare() - exoPlayer?.play() - } } override fun onResume() { @@ -142,9 +116,6 @@ class PlayerFragment : Fragment(), SurfaceHolder.Callback { if (playerView != null && playerView!!.player?.isPlaying == true) { playerView!!.player?.stop() } - if (exoPlayer?.isPlaying == true) { - exoPlayer?.stop() - } } override fun onDestroy() { @@ -152,7 +123,6 @@ class PlayerFragment : Fragment(), SurfaceHolder.Callback { if (playerView != null) { playerView!!.player?.release() } - exoPlayer?.release() } override fun onDestroyView() { @@ -163,16 +133,4 @@ class PlayerFragment : Fragment(), SurfaceHolder.Callback { companion object { private const val TAG = "PlayerFragment" } - - override fun surfaceCreated(holder: SurfaceHolder) { - exoPlayer = SimpleExoPlayer.Builder(requireContext()).build() - exoPlayer?.setVideoSurfaceHolder(surfaceHolder) - exoPlayer?.playWhenReady = true - } - - override fun surfaceChanged(holder: SurfaceHolder, format: Int, width: Int, height: Int) { - } - - override fun surfaceDestroyed(holder: SurfaceHolder) { - } } \ No newline at end of file diff --git a/app/src/main/java/com/lizongying/mytv/api/ApiClient.kt b/app/src/main/java/com/lizongying/mytv/api/ApiClient.kt index aab455f5..4b196ea3 100644 --- a/app/src/main/java/com/lizongying/mytv/api/ApiClient.kt +++ b/app/src/main/java/com/lizongying/mytv/api/ApiClient.kt @@ -3,6 +3,7 @@ package com.lizongying.mytv.api import android.os.Build import android.util.Log +import com.google.gson.Gson import com.lizongying.mytv.jce.JceConverterFactory import com.lizongying.mytv.requests.ReleaseService import okhttp3.ConnectionSpec @@ -11,8 +12,6 @@ import okhttp3.TlsVersion import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory import retrofit2.converter.protobuf.ProtoConverterFactory -import java.net.InetSocketAddress -import java.net.Proxy import javax.net.ssl.SSLContext import javax.net.ssl.TrustManager import javax.net.ssl.X509TrustManager @@ -30,12 +29,13 @@ class ApiClient { private val fUrl = "https://m.fengshows.com/" private var okHttpClient = getUnsafeOkHttpClient() + private var gson = Gson() val yspApiService: YSPApiService by lazy { Retrofit.Builder() .baseUrl(yspUrl) .client(okHttpClient) - .addConverterFactory(GsonConverterFactory.create()) + .addConverterFactory(GsonConverterFactory.create(gson)) .build().create(YSPApiService::class.java) } @@ -43,7 +43,7 @@ class ApiClient { Retrofit.Builder() .baseUrl(myUrl) .client(okHttpClient) - .addConverterFactory(GsonConverterFactory.create()) + .addConverterFactory(GsonConverterFactory.create(gson)) .build().create(YSPTokenService::class.java) } @@ -51,7 +51,7 @@ class ApiClient { Retrofit.Builder() .baseUrl(HOST) .client(okHttpClient) - .addConverterFactory(GsonConverterFactory.create()) + .addConverterFactory(GsonConverterFactory.create(gson)) .build().create(ReleaseService::class.java) } @@ -67,7 +67,7 @@ class ApiClient { Retrofit.Builder() .baseUrl(traceUrl) .client(okHttpClient) - .addConverterFactory(GsonConverterFactory.create()) + .addConverterFactory(GsonConverterFactory.create(gson)) .build().create(YSPBtraceService::class.java) } @@ -75,7 +75,7 @@ class ApiClient { Retrofit.Builder() .baseUrl(trace2Url) .client(okHttpClient) - .addConverterFactory(GsonConverterFactory.create()) + .addConverterFactory(GsonConverterFactory.create(gson)) .build().create(YSPBtraceService::class.java) } @@ -83,7 +83,7 @@ class ApiClient { Retrofit.Builder() .baseUrl(tokenUrl) .client(okHttpClient) - .addConverterFactory(GsonConverterFactory.create()) + .addConverterFactory(GsonConverterFactory.create(gson)) .build().create(YSPApiService::class.java) } @@ -91,7 +91,7 @@ class ApiClient { Retrofit.Builder() .baseUrl(trace3Url) .client(okHttpClient) - .addConverterFactory(GsonConverterFactory.create()) + .addConverterFactory(GsonConverterFactory.create(gson)) .build().create(YSPBtraceService::class.java) } @@ -107,7 +107,7 @@ class ApiClient { Retrofit.Builder() .baseUrl(fUrl) .client(okHttpClient) - .addConverterFactory(GsonConverterFactory.create()) + .addConverterFactory(GsonConverterFactory.create(gson)) .build().create(FAuthService::class.java) } diff --git a/app/src/main/res/layout/player.xml b/app/src/main/res/layout/player.xml index ee8d71af..1c034b81 100644 --- a/app/src/main/res/layout/player.xml +++ b/app/src/main/res/layout/player.xml @@ -6,15 +6,6 @@ android:layout_height="match_parent" android:background="@color/black" android:keepScreenOn="true"> - - -