Skip to content

Commit

Permalink
tracks video integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaji Khan committed Mar 15, 2024
1 parent b505db9 commit 183994f
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 9 deletions.
3 changes: 2 additions & 1 deletion app/src/main/java/com/shajikhan/ladspa/amprack/Camera2.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public void createCameraPreview() {
SurfaceTexture texture = textureView.getSurfaceTexture();
assert texture != null;
// fixme: change this!
imageDimension = new Size (320, 240);
imageDimension = new Size (1280, 720);
texture.setDefaultBufferSize(imageDimension.getWidth(), imageDimension.getHeight());
Log.d(TAG, "createCameraPreview: created surface with dimensions" + ":".format (" %d x %d", imageDimension.getWidth(), imageDimension.getHeight()));
Surface surface = new Surface(texture);
Expand Down Expand Up @@ -427,6 +427,7 @@ public void onOutputBufferAvailable(@NonNull MediaCodec codec, int index, @NonNu

// now that we have the Magic Goodies, start the muxer
mTrackIndex = mMuxer.addTrack(newFormat);
mMuxer.setOrientationHint(cameraCharacteristicsHashMap.get(cameraId).get(CameraCharacteristics.SENSOR_ORIENTATION));
mMuxer.start();
mMuxerStarted = true;
}
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/java/com/shajikhan/ladspa/amprack/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,12 @@ public void surfaceDestroyed(SurfaceHolder holder) {
});

ToggleButton toggleButton = constraintLayout.findViewById(R.id.media_play);
surface.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
toggleButton.setChecked(false);
}
});
Button openFolder = constraintLayout.findViewById(R.id.open_folder);
openFolder.setOnClickListener(new View.OnClickListener() {
@Override
Expand All @@ -902,6 +908,7 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if (b) {
Uri uri = Uri.parse(lastRecordedFileName);
try {
surface.setVisibility(View.VISIBLE);
mediaPlayer.stop();
mediaPlayer.reset();
mediaPlayer.setDataSource(getApplicationContext(), uri);
Expand All @@ -911,11 +918,13 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
toast("Cannot load media file: " + e.getMessage());
return;
}

toggleButton.setButtonDrawable(R.drawable.ic_baseline_pause_24);
mediaPlayer.start();
} else {
mediaPlayer.pause();
toggleButton.setButtonDrawable(R.drawable.ic_baseline_play_arrow_24);
surface.setVisibility(View.GONE);
}
}
});
Expand All @@ -926,6 +935,7 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
public void onCompletion(MediaPlayer mediaPlayer) {
toggleButton.setButtonDrawable(R.drawable.ic_baseline_play_arrow_24);
seekBar.setProgress(0);
surface.setVisibility(View.GONE);
}
});

Expand Down Expand Up @@ -2647,6 +2657,9 @@ static public String readAssetFile(Context context, String filename) {
}

public void testLV2 () {
Log.d(TAG, "testLV2: " +
String.format("%d\t%d",
getDisplayRotation(),getCameraSensorOrientation(camera2.cameraCharacteristicsHashMap.get(camera2.cameraId))));
// Log.d(TAG, "testLV2: " + getLV2Info("eql"));
// AudioEngine.testLV2();
AudioDeviceInfo[] audioDevicesInput, audioDevicesOutput ;
Expand Down
18 changes: 15 additions & 3 deletions app/src/main/java/com/shajikhan/ladspa/amprack/Tracks.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ToggleButton;

Expand All @@ -29,10 +30,12 @@

import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.analytics.AnalyticsListener;
import com.google.android.exoplayer2.audio.AuxEffectInfo;
import com.google.android.exoplayer2.video.VideoSize;
import com.google.android.material.slider.Slider;

import java.io.File;
Expand Down Expand Up @@ -96,6 +99,7 @@ public void surfaceDestroyed(@NonNull SurfaceHolder holder) {
});

LinearLayout shareTip = view.findViewById(R.id.share_tip);
FrameLayout frameLayout = view.findViewById(R.id.vframe);
recyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
Expand All @@ -112,6 +116,12 @@ public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {

playPause = view.findViewById(R.id.tracks_play);
tracksAdapter.tracks = this;
frameLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
playPause.setChecked(false);
}
});
playPause.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
Expand All @@ -123,16 +133,18 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if (!b) {
playPause.setBackgroundDrawable(getResources().getDrawable(R.drawable.ic_baseline_play_arrow_24));
player.pause();
surfaceView.setVisibility(View.GONE);
frameLayout.setVisibility(View.GONE);
if (mainActivity.useTheme) {
if (pause != null)
playPause.setCompoundDrawables(pause, null, null, null);
}
} else {
playPause.setBackgroundDrawable(getResources().getDrawable(R.drawable.ic_baseline_pause_24));
player.play();
if (player.getVideoFormat() != null)
surfaceView.setVisibility(View.VISIBLE);
if (player.getVideoFormat() != null) {
frameLayout.setVisibility(View.VISIBLE);
}

if (mainActivity.useTheme) {
if (pause != null)
playPause.setCompoundDrawables(play, null, null, null);
Expand Down
12 changes: 11 additions & 1 deletion app/src/main/res/layout/media_player_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
<SurfaceView
android:layout_width="match_parent"
android:id="@+id/video_player_dialog"
android:layout_height="200dp"/>
android:layout_height="wrap_content"
android:visibility="gone"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down Expand Up @@ -60,6 +61,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAlignment="viewStart"
android:id="@+id/share_file"
android:text="Share"
android:fontFamily="@font/comfortaa"
Expand All @@ -73,6 +75,14 @@
android:background="@color/fui_transparent"
android:drawableRight="@drawable/ic_baseline_delete_forever_24"/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:fontFamily="@font/comfortaa"
android:textColor="@color/white"
android:layout_marginBottom="10dp"
android:text="Tap video to close"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down
14 changes: 10 additions & 4 deletions app/src/main/res/layout/tracks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@
app:layout_constraintTop_toTopOf="parent"
android:orientation="vertical"
app:layout_constraintLeft_toLeftOf="parent">
<SurfaceView
android:layout_width="match_parent"
android:layout_height="300dp"
<FrameLayout
android:layout_width="wrap_content"
android:id="@+id/vframe"
android:visibility="gone"
android:id="@+id/tracks_video"/>
android:layout_height="wrap_content">

<SurfaceView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tracks_video"/>
</FrameLayout>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down

0 comments on commit 183994f

Please sign in to comment.