Fullscreen Button

This commit is contained in:
Stefan Schueller 2018-12-29 15:09:20 +01:00
parent f468a9998f
commit d7d597f235
3 changed files with 34 additions and 21 deletions

View File

@ -35,6 +35,7 @@ import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.PopupMenu;
import android.util.Log;
import android.util.TypedValue;
import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
@ -54,6 +55,7 @@ import com.github.se_bastiaan.torrentstream.TorrentStream;
import com.github.se_bastiaan.torrentstream.listeners.TorrentListener;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.decoder.DecoderCounters;
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
import com.google.android.exoplayer2.ui.PlayerView;
import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.VideoRendererEventListener;
@ -134,6 +136,9 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere
simpleExoPlayerView = new PlayerView(this);
simpleExoPlayerView = findViewById(R.id.video_view);
simpleExoPlayerView.setControllerShowTimeoutMs(1000);
simpleExoPlayerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FIT);
// Full screen Icon
fullscreenButton = findViewById(R.id.exo_fullscreen);
fullscreenButton.setText(R.string.video_expand_icon);
@ -243,7 +248,7 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) simpleExoPlayerView.getLayoutParams();
params.width = ViewGroup.LayoutParams.MATCH_PARENT;
params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
params.height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 250, getResources().getDisplayMetrics());
simpleExoPlayerView.setLayoutParams(params);
nameView.setVisibility(View.VISIBLE);
@ -440,11 +445,11 @@ public class VideoPlayActivity extends AppCompatActivity implements VideoRendere
@Override
protected void onStart() {
super.onStart();
//
// if (!mBound) {
// videoPlayerIntent = new Intent(this, VideoPlayerService.class);
// bindService(videoPlayerIntent, mConnection, Context.BIND_AUTO_CREATE);
// }
if (!mBound) {
videoPlayerIntent = new Intent(this, VideoPlayerService.class);
bindService(videoPlayerIntent, mConnection, Context.BIND_AUTO_CREATE);
}
Log.v(TAG, "onStart()...");
}

View File

@ -18,11 +18,10 @@
android:layout_width="match_parent"
android:layout_height="250dp"
android:background="@color/videoBackgroundColor"
app:resize_mode="fixed_width"
app:controller_layout_id="@layout/video_playback_controls"
app:layout_constraintDimensionRatio="H,3:1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
/>
<ProgressBar
android:id="@+id/progress"

View File

@ -86,7 +86,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:gravity="center_vertical"
android:layout_gravity="center"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:textColor="#FFBEBEBE"
@ -102,23 +102,32 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:gravity="center_vertical"
android:layout_gravity="center"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:textColor="#FFBEBEBE"
android:textSize="14sp" />
<TextView
android:id="@+id/exo_fullscreen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="true"
android:paddingStart="6dp"
android:paddingEnd="6dp"
android:textColor="#FFBEBEBE"
android:textSize="12sp" />
<FrameLayout
android:id="@+id/exo_fullscreen_button"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="end">
<TextView
android:id="@+id/exo_fullscreen"
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:textColor="#FFBEBEBE"
android:textSize="12sp" />
</FrameLayout>
</LinearLayout>
<LinearLayout