Untitled

mail@pastecode.io avatar
unknown
plain_text
16 days ago
1.2 kB
1
Indexable
Never
import android.net.Uri;
import android.os.Bundle;
import android.widget.Button;
import android.widget.VideoView;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private static final String INPUT_FILE1 = "/path/to/your/first/video.mp4";
    private static final String INPUT_FILE2 = "/path/to/your/second/video.mp4";
    private static final String OUTPUT_FILE = "/path/to/your/output/merged_video.mp4";

    private VideoView videoView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        videoView = findViewById(R.id.videoView);
        Button mergeButton = findViewById(R.id.mergeButton);
        Button playButton = findViewById(R.id.playButton);

        mergeButton.setOnClickListener(v -> {
            VideoMerger videoMerger = new VideoMerger();
            videoMerger.mergeVideos(INPUT_FILE1, INPUT_FILE2, OUTPUT_FILE);
        });

        playButton.setOnClickListener(v -> playMergedVideo());
    }

    private void playMergedVideo() {
        videoView.setVideoURI(Uri.parse(OUTPUT_FILE));
        videoView.start();
    }
}
Leave a Comment