track metadata on player interface
This commit is contained in:
parent
1319cf8a84
commit
caac4c3d66
3 changed files with 33 additions and 5 deletions
|
@ -9,7 +9,7 @@ android {
|
|||
applicationId "asgardius.page.s3music"
|
||||
minSdk 21
|
||||
targetSdk 33
|
||||
versionCode 1
|
||||
versionCode 3
|
||||
versionName "0.0.0"
|
||||
setProperty("archivesBaseName", "s3-music-$versionName")
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import android.os.PowerManager;
|
|||
import android.support.v4.media.session.MediaSessionCompat;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
@ -22,6 +23,7 @@ import com.google.android.exoplayer2.DefaultLoadControl;
|
|||
import com.google.android.exoplayer2.DefaultRenderersFactory;
|
||||
import com.google.android.exoplayer2.ExoPlayer;
|
||||
import com.google.android.exoplayer2.MediaItem;
|
||||
import com.google.android.exoplayer2.MediaMetadata;
|
||||
import com.google.android.exoplayer2.PlaybackException;
|
||||
import com.google.android.exoplayer2.Player;
|
||||
import com.google.android.exoplayer2.audio.AudioAttributes;
|
||||
|
@ -53,6 +55,7 @@ public class VideoPlayer extends AppCompatActivity {
|
|||
private PowerManager.WakeLock mWakeLock;
|
||||
private PowerManager powerManager;
|
||||
private long maxCacheSize;
|
||||
private TextView tn,an;
|
||||
ImageView previous, playpause, next;
|
||||
ArrayList<String> queue, names;
|
||||
LeastRecentlyUsedCacheEvictor evictor;
|
||||
|
@ -71,7 +74,7 @@ public class VideoPlayer extends AppCompatActivity {
|
|||
private int notificationId = 1234;
|
||||
boolean isplaylist;
|
||||
boolean success = false;
|
||||
String videoURL, title;
|
||||
String videoURL, title, artistname, trackname;
|
||||
|
||||
public static String URLify(String str) {
|
||||
str = str.trim();
|
||||
|
@ -112,6 +115,8 @@ public class VideoPlayer extends AppCompatActivity {
|
|||
next = (ImageView) findViewById(R.id.next);
|
||||
play = getResources().getDrawable(R.drawable.play);
|
||||
pause = getResources().getDrawable(R.drawable.pause);
|
||||
an = (TextView) findViewById(R.id.artistname);
|
||||
tn = (TextView) findViewById(R.id.trackname);
|
||||
|
||||
previous.setOnClickListener(new View.OnClickListener(){
|
||||
@Override
|
||||
|
@ -261,6 +266,15 @@ public class VideoPlayer extends AppCompatActivity {
|
|||
}
|
||||
Player.Listener.super.onIsPlayingChanged(isPlaying);
|
||||
}
|
||||
|
||||
public void onMediaMetadataChanged(MediaMetadata mediaMetadata) {
|
||||
//Station 5 does not display metadata
|
||||
trackname = (String) mediaMetadata.title;
|
||||
tn.setText(trackname);
|
||||
artistname = (String) mediaMetadata.artist;
|
||||
an.setText(artistname);
|
||||
//System.out.println(trackname);
|
||||
}
|
||||
});
|
||||
|
||||
player.addListener(new Player.Listener() {
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="200dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_weight="0" >
|
||||
|
||||
|
@ -30,14 +30,28 @@
|
|||
android:id="@+id/control_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="20dp"
|
||||
android:padding="5dp"
|
||||
app:bar_height="30dp"
|
||||
app:show_timeout="0"
|
||||
app:controller_layout_id="@layout/player_custom_controls" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/trackname"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="30sp"
|
||||
android:textAlignment="center"
|
||||
android:textSize="25sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/artistname"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="30sp"
|
||||
android:textAlignment="center"
|
||||
android:textSize="25sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="100dp"
|
||||
android:layout_height="80dp"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center">
|
||||
|
||||
|
|
Loading…
Reference in a new issue