Преглед на файлове

switched to exoplayer 2.11.0. added some debug to the metadata

yattoz преди 4 години
родител
ревизия
836da0f80f
променени са 2 файла, в които са добавени 17 реда и са изтрити 4 реда
  1. 1 1
      app/build.gradle
  2. 16 3
      app/src/main/java/fr/forum_thalie/tsumugi/RadioService.kt

+ 1 - 1
app/build.gradle Целия файл

@@ -64,7 +64,7 @@ dependencies {
64 64
      */
65 65
 
66 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 68
     implementation 'androidx.legacy:legacy-support-v4:1.0.0'
69 69
     implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
70 70
     implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.1.0'

+ 16 - 3
app/src/main/java/fr/forum_thalie/tsumugi/RadioService.kt Целия файл

@@ -32,11 +32,11 @@ import androidx.media.AudioManagerCompat
32 32
 import androidx.preference.PreferenceManager
33 33
 import com.google.android.exoplayer2.*
34 34
 import com.google.android.exoplayer2.metadata.icy.*
35
-import com.google.android.exoplayer2.trackselection.DefaultTrackSelector
36 35
 import fr.forum_thalie.tsumugi.alarm.RadioAlarm
37 36
 import fr.forum_thalie.tsumugi.alarm.RadioSleeper
38 37
 import fr.forum_thalie.tsumugi.playerstore.PlayerStore
39 38
 import java.util.*
39
+import kotlin.collections.ArrayList
40 40
 import kotlin.math.exp
41 41
 import kotlin.math.ln
42 42
 import kotlin.system.exitProcess
@@ -348,7 +348,10 @@ class RadioService : MediaBrowserServiceCompat() {
348 348
             setBufferDurationsMs(minBufferMillis, maxBufferMillis, bufferForPlayback, bufferForPlaybackAfterRebuffer)
349 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 355
         player.addMetadataOutput {
353 356
             for (i in 0 until it.length()) {
354 357
                 val entry  = it.get(i)
@@ -356,9 +359,19 @@ class RadioService : MediaBrowserServiceCompat() {
356 359
                     Log.d(tag, radioTag + "onMetadata: IcyHeaders $entry")
357 360
                 }
358 361
                 if (entry is IcyInfo) {
359
-                    Log.d(tag, radioTag + "onMetadata: Title ----> ${entry.title}")
362
+                    Log.e(tag, radioTag + "onMetadata: Title ----> ${entry.title}")
360 363
                     // Note : Kotlin supports UTF-8 by default.
361 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 375
                     val data = entry.title!!
363 376
                     PlayerStore.instance.currentSong.setTitleArtist(data)
364 377
                 }