title: How to extract timed ID3 metadata from HLS stream in ExoPlayer?
body: <p>I have an M3U8 file located here: <a href="https://vcloud.blueframetech.com/file/hls/13836.m3u8" rel="nofollow noreferrer">https://vcloud.blueframetech.com/file/hls/13836.m3u8</a></p>
  
  <p>This video contains timed metadata every single second. My goal is to read this metadata from ExoPlayer. I currently have the following in my <code>MainActivity.java</code>:</p>
  
  <pre><code>package com.test.exoplayermetadatatest;
  
  import androidx.appcompat.app.AppCompatActivity;
  
  import android.content.Context;
  import android.net.Uri;
  import android.os.Bundle;
  import android.util.Log;
  
  import com.google.android.exoplayer2.ExoPlayerFactory;
  import com.google.android.exoplayer2.Player;
  import com.google.android.exoplayer2.SimpleExoPlayer;
  import com.google.android.exoplayer2.metadata.Metadata;
  import com.google.android.exoplayer2.metadata.MetadataOutput;
  import com.google.android.exoplayer2.source.MediaSource;
  import com.google.android.exoplayer2.source.ProgressiveMediaSource;
  import com.google.android.exoplayer2.source.TrackGroup;
  import com.google.android.exoplayer2.source.TrackGroupArray;
  import com.google.android.exoplayer2.source.hls.HlsMediaSource;
  import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
  import com.google.android.exoplayer2.ui.PlayerView;
  import com.google.android.exoplayer2.upstream.DataSource;
  import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
  import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory;
  import com.google.android.exoplayer2.util.Util;
  
  public class MainActivity extends AppCompatActivity implements MetadataOutput, Player.EventListener
  {
  
      @Override
      protected void onCreate ( Bundle savedInstanceState )
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          Context context = getApplicationContext();
  
          SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(context);
  
          PlayerView view = findViewById(R.id.player);
  
          view.setPlayer(player);
  
          DataSource.Factory dataSourceFactory =
              new DefaultHttpDataSourceFactory(Util.getUserAgent(context, "app-name"));
  
          HlsMediaSource hlsMediaSource =
              new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse("https://vcloud.blueframetech.com/file/hls/13836.m3u8"));
  
          player.addMetadataOutput(this);
          player.addListener(this);
  
          player.prepare(hlsMediaSource);
  
          player.setPlayWhenReady(true);
      }
  
      @Override
      public void onTracksChanged( TrackGroupArray trackGroups, TrackSelectionArray trackSelections)
      {
          for ( int i = 0; i &lt; trackGroups.length; i++ )
          {
              TrackGroup trackGroup = trackGroups.get(i);
              for ( int j = 0; j &lt; trackGroup.length; j++ )
              {
                  Metadata trackMetadata = trackGroup.getFormat(j).metadata;
                  if ( trackMetadata != null )
                  {
                      Log.d("METADATA TRACK", trackMetadata.toString());
                  }
              }
          }
      }
  
      @Override
      public void onMetadata ( Metadata metadata )
      {
          Log.d("METADATA", metadata.toString());
      }
  
  }
  </code></pre>
  
  <p>When the app loads I see the <code>METADATA TRACK</code> log appear a single time, but the <code>METADATA</code> log never appears once. What am I missing or doing wrong?</p>