Browse Source

switched to exoplayer 2.11.0. added some debug to the metadata

yattoz 4 years ago
parent
commit
836da0f80f
2 changed files with 17 additions and 4 deletions
  1. 1 1
      app/build.gradle
  2. 16 3
      app/src/main/java/fr/forum_thalie/tsumugi/RadioService.kt

+ 1 - 1
app/build.gradle View File

64
      */
64
      */
65
 
65
 
66
     implementation "androidx.media:media:1.1.0"
66
     implementation "androidx.media:media:1.1.0"
67
-    implementation 'com.google.android.exoplayer:exoplayer:2.10.6'
67
+    implementation 'com.google.android.exoplayer:exoplayer:2.11.0'
68
     implementation 'androidx.legacy:legacy-support-v4:1.0.0'
68
     implementation 'androidx.legacy:legacy-support-v4:1.0.0'
69
     implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
69
     implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
70
     implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.1.0'
70
     implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.1.0'

+ 16 - 3
app/src/main/java/fr/forum_thalie/tsumugi/RadioService.kt View File

32
 import androidx.preference.PreferenceManager
32
 import androidx.preference.PreferenceManager
33
 import com.google.android.exoplayer2.*
33
 import com.google.android.exoplayer2.*
34
 import com.google.android.exoplayer2.metadata.icy.*
34
 import com.google.android.exoplayer2.metadata.icy.*
35
-import com.google.android.exoplayer2.trackselection.DefaultTrackSelector
36
 import fr.forum_thalie.tsumugi.alarm.RadioAlarm
35
 import fr.forum_thalie.tsumugi.alarm.RadioAlarm
37
 import fr.forum_thalie.tsumugi.alarm.RadioSleeper
36
 import fr.forum_thalie.tsumugi.alarm.RadioSleeper
38
 import fr.forum_thalie.tsumugi.playerstore.PlayerStore
37
 import fr.forum_thalie.tsumugi.playerstore.PlayerStore
39
 import java.util.*
38
 import java.util.*
39
+import kotlin.collections.ArrayList
40
 import kotlin.math.exp
40
 import kotlin.math.exp
41
 import kotlin.math.ln
41
 import kotlin.math.ln
42
 import kotlin.system.exitProcess
42
 import kotlin.system.exitProcess
348
             setBufferDurationsMs(minBufferMillis, maxBufferMillis, bufferForPlayback, bufferForPlaybackAfterRebuffer)
348
             setBufferDurationsMs(minBufferMillis, maxBufferMillis, bufferForPlayback, bufferForPlaybackAfterRebuffer)
349
         }.createDefaultLoadControl()
349
         }.createDefaultLoadControl()
350
 
350
 
351
-        player = ExoPlayerFactory.newSimpleInstance(this, DefaultTrackSelector(), loadControl)
351
+        val playerBuilder = SimpleExoPlayer.Builder(this)
352
+        playerBuilder.setLoadControl(loadControl)
353
+        player = playerBuilder.build()
354
+
352
         player.addMetadataOutput {
355
         player.addMetadataOutput {
353
             for (i in 0 until it.length()) {
356
             for (i in 0 until it.length()) {
354
                 val entry  = it.get(i)
357
                 val entry  = it.get(i)
356
                     Log.d(tag, radioTag + "onMetadata: IcyHeaders $entry")
359
                     Log.d(tag, radioTag + "onMetadata: IcyHeaders $entry")
357
                 }
360
                 }
358
                 if (entry is IcyInfo) {
361
                 if (entry is IcyInfo) {
359
-                    Log.d(tag, radioTag + "onMetadata: Title ----> ${entry.title}")
362
+                    Log.e(tag, radioTag + "onMetadata: Title ----> ${entry.title}")
360
                     // Note : Kotlin supports UTF-8 by default.
363
                     // Note : Kotlin supports UTF-8 by default.
361
                     numberOfSongs++
364
                     numberOfSongs++
365
+                    val s = entry.title!!
366
+                    val a = ArrayList<Int>()
367
+
368
+                    for (j in s.indices)
369
+                    {
370
+                        a.add(s[j].toInt())
371
+
372
+                    }
373
+                    Log.e(tag, a.toString())
374
+                    Log.e(tag, "raw: ${it}")
362
                     val data = entry.title!!
375
                     val data = entry.title!!
363
                     PlayerStore.instance.currentSong.setTitleArtist(data)
376
                     PlayerStore.instance.currentSong.setTitleArtist(data)
364
                 }
377
                 }