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