Add play short-cut button
This commit is contained in:
@@ -370,6 +370,11 @@ public class MainActivity extends AppCompatActivity {
|
||||
openFilePicker();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTestButtonClicked() {
|
||||
loadAndPlayTestVideo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayPauseClicked() {
|
||||
VulkanVideoView.PlaybackState state = vulkanVideoView.getPlaybackState();
|
||||
@@ -644,6 +649,40 @@ public class MainActivity extends AppCompatActivity {
|
||||
return String.format("%02d:%02d", minutes, seconds);
|
||||
}
|
||||
|
||||
private void loadAndPlayTestVideo() {
|
||||
String testFilePath = "/storage/emulated/0/Download/output.webm";
|
||||
String fileName = "output.webm";
|
||||
|
||||
android.util.Log.i(TAG, "Test button clicked: Loading " + testFilePath);
|
||||
|
||||
boolean success = vulkanVideoView.loadVideo(testFilePath);
|
||||
if (success) {
|
||||
VideoInfo info = vulkanVideoView.getVideoInfo();
|
||||
if (info != null) {
|
||||
statusText.setText(String.format("Test: %s (%dx%d, %.1f fps)",
|
||||
fileName, info.width, info.height, info.frameRate));
|
||||
vulkanVideoView.setVideoSize(info.width, info.height);
|
||||
|
||||
// Set video duration for progress tracking
|
||||
videoDurationUs = info.durationUs;
|
||||
|
||||
// Update overlay with video info
|
||||
videoPlayerOverlay.setVideoTitle("TEST: " + fileName);
|
||||
videoPlayerOverlay.updateProgress(0, videoDurationUs);
|
||||
videoPlayerOverlay.showPlaybackControls();
|
||||
videoPlayerOverlay.show();
|
||||
|
||||
// Auto-start playback after a short delay
|
||||
new android.os.Handler(android.os.Looper.getMainLooper()).postDelayed(() -> {
|
||||
playVideo();
|
||||
android.util.Log.i(TAG, "Test video playback started");
|
||||
}, 200);
|
||||
}
|
||||
} else {
|
||||
showError("Failed to load test video: " + testFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupSystemBars() {
|
||||
// Set up window insets listener to handle system bars properly
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(android.R.id.content), (v, insets) -> {
|
||||
|
||||
@@ -21,6 +21,7 @@ public class VideoPlayerOverlay extends FrameLayout {
|
||||
private ImageButton backButton;
|
||||
private TextView videoTitle;
|
||||
private ImageButton loadVideoButton;
|
||||
private ImageButton testButton;
|
||||
private ImageButton optionsButton;
|
||||
private ImageButton centerPlayButton;
|
||||
private ImageButton playButton;
|
||||
@@ -40,6 +41,7 @@ public class VideoPlayerOverlay extends FrameLayout {
|
||||
public interface OverlayListener {
|
||||
void onBackClicked();
|
||||
void onLoadVideoClicked();
|
||||
void onTestButtonClicked();
|
||||
void onPlayPauseClicked();
|
||||
void onStopClicked();
|
||||
void onSeekTo(long positionUs);
|
||||
@@ -64,6 +66,7 @@ public class VideoPlayerOverlay extends FrameLayout {
|
||||
backButton = findViewById(R.id.back_button);
|
||||
videoTitle = findViewById(R.id.video_title);
|
||||
loadVideoButton = findViewById(R.id.load_video_button);
|
||||
testButton = findViewById(R.id.test_button);
|
||||
optionsButton = findViewById(R.id.more_options);
|
||||
centerPlayButton = findViewById(R.id.center_play_pause);
|
||||
playButton = findViewById(R.id.overlay_play_button);
|
||||
@@ -91,6 +94,12 @@ public class VideoPlayerOverlay extends FrameLayout {
|
||||
}
|
||||
});
|
||||
|
||||
testButton.setOnClickListener(v -> {
|
||||
if (listener != null) {
|
||||
listener.onTestButtonClicked();
|
||||
}
|
||||
});
|
||||
|
||||
optionsButton.setOnClickListener(v -> {
|
||||
if (listener != null) {
|
||||
listener.onOptionsClicked();
|
||||
|
||||
@@ -62,6 +62,15 @@
|
||||
android:contentDescription="@string/content_description_load_button"
|
||||
android:tint="@android:color/white" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/test_button"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:src="@drawable/ic_play_arrow"
|
||||
android:contentDescription="Test Button"
|
||||
android:tint="#00FF00" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/more_options"
|
||||
android:layout_width="48dp"
|
||||
|
||||
Reference in New Issue
Block a user