save Video Code

 avatar
unknown
java
4 years ago
1.7 kB
8
Indexable
videoFile thi video Exoplayer thi play thay 6. atle videofile a currupt to nathi.

 public void SaveVideo(File videoFile) {
        try {
            Log.d("VideoURL",videoFile.getAbsolutePath());
            //--AboveLog-> "/data/user/0/lyrical.photovideo.maker.withmusic/NewWave/video_28_05_2021_11_05_34.mp4"

            InputStream in = getResources().openRawResource(R.raw.watermark); // aya mare project ni file nathi atle shu rakhvu.
            String filename = getResources().getResourceEntryName(R.raw.watermark);

            if (!videoFile.exists()){ // je videofile apnne male 6 te.
                try {
                    OutputStream out = new FileOutputStream(videoFile);
                    byte[] buffer = new byte[1024];
                    int len;
                    while ((len = in.read(buffer,0,buffer.length)) != -1){
                        out.write(buffer,0,len);
                    }
                    in.close();
                    out.close();

                }catch (Exception e){
                    e.printStackTrace();
                }
            }

            MediaScannerConnection.scanFile(context, new String[]{videoFile.getAbsolutePath()}, new String[]{"video/mp4"} , new MediaScannerConnection.OnScanCompletedListener() {
                @Override
                public void onScanCompleted(String path, Uri uri) {
                    Toast.makeText(context, "Scan Completed.", Toast.LENGTH_SHORT).show();
                }
            });


        }catch (Exception e){
            e.printStackTrace();
            Toast.makeText(context, "Album Cant Create.", Toast.LENGTH_SHORT).show();

        }
    }
Editor is loading...