playback buttons

This commit is contained in:
Page Asgardius 2023-02-24 10:47:26 -07:00
parent 4af39b75e2
commit 57a17845fb
8 changed files with 102 additions and 6 deletions

View file

@ -34,4 +34,11 @@
<component name="ProjectType">
<option name="id" value="Android" />
</component>
<component name="VisualizationToolProject">
<option name="state">
<ProjectState>
<option name="scale" value="0.02024678484532499" />
</ProjectState>
</option>
</component>
</project>

View file

@ -12,6 +12,7 @@
<li>Amazon Web Services SDK 2.64.0</li>
<li>ExoPlayer 2.18.3</li>
<li>Adwaita Icon Theme for GNOME 43</li>
<li>Font Awesome icons</li>
</ul>
<H3>This software released under GNU General Public License 3</H3>
<p>You can find source code at patrice.asgardius.company/gitea/asgardius/s3music

View file

@ -4,12 +4,15 @@ import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Bundle;
import android.os.PowerManager;
import android.support.v4.media.session.MediaSessionCompat;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
@ -48,10 +51,12 @@ public class VideoPlayer extends AppCompatActivity {
private PowerManager.WakeLock mWakeLock;
private PowerManager powerManager;
private long maxCacheSize;
ImageView previous, playpause, next;
ArrayList<String> queue, names;
LeastRecentlyUsedCacheEvictor evictor;
StandaloneDatabaseProvider standaloneDatabaseProvider;
SimpleCache simpleCache;
Drawable play, pause;
int videocache, buffersize;
ProgressiveMediaSource mediaSource;
DefaultLoadControl loadControl;
@ -100,6 +105,37 @@ public class VideoPlayer extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video_player);
previous = (ImageView) findViewById(R.id.previous);
playpause = (ImageView) findViewById(R.id.play);
next = (ImageView) findViewById(R.id.next);
play = getResources().getDrawable(R.drawable.play);
pause = getResources().getDrawable(R.drawable.pause);
previous.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
//buttonaction
player.seekToPreviousMediaItem();
}
});
playpause.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
//buttonaction
if(player.isPlaying()) {
player.pause();
} else {
player.play();
}
}
});
next.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
//buttonaction
player.seekToNextMediaItem();
}
});
if(Build.VERSION.SDK_INT >=Build.VERSION_CODES.O){
NotificationChannel channel= new NotificationChannel("playback","Video Playback", NotificationManager.IMPORTANCE_DEFAULT);
@ -210,7 +246,15 @@ public class VideoPlayer extends AppCompatActivity {
}
}
@Override
public void onIsPlayingChanged(boolean isPlaying) {
if(player.isPlaying()) {
playpause.setImageDrawable(pause);
} else {
playpause.setImageDrawable(play);
}
Player.Listener.super.onIsPlayingChanged(isPlaying);
}
});
player.addListener(new Player.Listener() {

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View file

@ -1,21 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="@style/ThemeOverlay.AsgardiusS3Manager.FullscreenContainer"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:gravity="top"
tools:context=".VideoPlayer">
<!-- The primary full-screen view. This can be replaced with whatever view
is needed to present your content, e.g. VideoView, SurfaceView,
TextureView, etc. -->
<!--Widget for exoplayer view-->
<com.google.android.exoplayer2.ui.StyledPlayerView
android:id="@+id/player_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="200dp"
android:padding="20dp"/>
android:padding="20dp"
android:layout_weight="2" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:orientation="vertical"
android:layout_weight="2" >
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center">
<ImageView
android:id="@+id/previous"
android:layout_width="70dp"
android:layout_height="70dp"
android:background="#000000"
android:scaleType="centerCrop"
android:layout_marginHorizontal="20dp"
app:srcCompat="@drawable/previous" />
<ImageView
android:id="@+id/play"
android:layout_width="70dp"
android:layout_height="70dp"
android:background="#000000"
android:scaleType="centerCrop"
android:layout_marginHorizontal="20dp"
app:srcCompat="@drawable/play" />
<ImageView
android:id="@+id/next"
android:layout_width="70dp"
android:layout_height="70dp"
android:background="#000000"
android:scaleType="centerCrop"
android:layout_marginHorizontal="20dp"
app:srcCompat="@drawable/next" />
</LinearLayout>
</LinearLayout>
</LinearLayout>