Browse Source

feat: 适配Android 11 sdk

hexleo 5 years ago
parent
commit
01647630dc

+ 1 - 1
Android/PlayerProj/animplayer/src/main/java/com/tencent/qgame/animplayer/AnimPlayer.kt

@@ -103,7 +103,7 @@ class AnimPlayer(val animView: AnimView) {
                 decoder?.start(fileContainer)
                 audioPlayer?.start(fileContainer)
             } else {
-                startRunnable = Runnable {
+                 startRunnable = Runnable {
                     innerStartPlay(fileContainer)
                 }
                 animView.prepareTextureView()

+ 4 - 4
Android/PlayerProj/animplayer/src/main/java/com/tencent/qgame/animplayer/AnimView.kt

@@ -104,15 +104,15 @@ open class AnimView @JvmOverloads constructor(context: Context, attrs: Attribute
         return innerTextureView?.surfaceTexture ?: surface
     }
 
-    override fun onSurfaceTextureSizeChanged(surface: SurfaceTexture?, width: Int, height: Int) {
+    override fun onSurfaceTextureSizeChanged(surface: SurfaceTexture, width: Int, height: Int) {
         ALog.i(TAG, "onSurfaceTextureSizeChanged $width x $height")
         player?.onSurfaceTextureSizeChanged(width, height)
     }
 
-    override fun onSurfaceTextureUpdated(surface: SurfaceTexture?) {
+    override fun onSurfaceTextureUpdated(surface: SurfaceTexture) {
     }
 
-    override fun onSurfaceTextureDestroyed(surface: SurfaceTexture?): Boolean {
+    override fun onSurfaceTextureDestroyed(surface: SurfaceTexture): Boolean {
         ALog.i(TAG, "onSurfaceTextureDestroyed")
         player?.onSurfaceTextureDestroyed()
         uiHandler.post {
@@ -123,7 +123,7 @@ open class AnimView @JvmOverloads constructor(context: Context, attrs: Attribute
         return !belowKitKat()
     }
 
-    override fun onSurfaceTextureAvailable(surface: SurfaceTexture?, width: Int, height: Int) {
+    override fun onSurfaceTextureAvailable(surface: SurfaceTexture, width: Int, height: Int) {
         ALog.i(TAG, "onSurfaceTextureAvailable")
         this.surface = surface
         player?.onSurfaceTextureAvailable(width, height)

+ 1 - 1
Android/PlayerProj/animplayer/src/main/java/com/tencent/qgame/animplayer/AudioPlayer.kt

@@ -74,7 +74,7 @@ class AudioPlayer(val player: AnimPlayer) {
         }
         extractor.selectTrack(audioIndex)
         val format = extractor.getTrackFormat(audioIndex)
-        val mime =format.getString(MediaFormat.KEY_MIME)
+        val mime =format.getString(MediaFormat.KEY_MIME) ?: ""
         val decoder = MediaCodec.createDecoderByType(mime).apply {
             configure(format, null, null, 0)
             start()

+ 1 - 1
Android/PlayerProj/animplayer/src/main/java/com/tencent/qgame/animplayer/HardDecoder.kt

@@ -109,7 +109,7 @@ class HardDecoder(player: AnimPlayer) : Decoder(player), SurfaceTexture.OnFrameA
 
 
         try {
-            val mime = format.getString(MediaFormat.KEY_MIME)
+            val mime = format.getString(MediaFormat.KEY_MIME) ?: ""
             ALog.i(TAG, "Video MIME is $mime")
             decoder = MediaCodec.createDecoderByType(mime).apply {
                 configure(format, Surface(glTexture), null, 0)

+ 2 - 2
Android/PlayerProj/animplayer/src/main/java/com/tencent/qgame/animplayer/util/MediaUtil.kt

@@ -34,7 +34,7 @@ object MediaUtil {
         val numTracks = extractor.trackCount
         for (i in 0 until numTracks) {
             val format = extractor.getTrackFormat(i)
-            val mime = format.getString(MediaFormat.KEY_MIME)
+            val mime = format.getString(MediaFormat.KEY_MIME) ?: ""
             if (mime.startsWith("video/")) {
                 ALog.d(TAG, "Extractor selected track $i ($mime): $format")
                 return i
@@ -47,7 +47,7 @@ object MediaUtil {
         val numTracks = extractor.trackCount
         for (i in 0 until numTracks) {
             val format = extractor.getTrackFormat(i)
-            val mime = format.getString(MediaFormat.KEY_MIME)
+            val mime = format.getString(MediaFormat.KEY_MIME) ?: ""
             if (mime.startsWith("audio/")) {
                 ALog.d(TAG, "Extractor selected track $i ($mime): $format")
                 return i