اذهب إلى المحتوى
  • 0

الحصول على مسار فيديو في java

خضر علي2

السؤال

Recommended Posts

  • 1

وعليكم السلام @خضر علي2

يمكنك القيام بذلك بعدة طرق  من خلال الحصول على البيانات الراجعة من ال Intent هكذا الميثود getPath يتم تمرير المسار من ال intent بعد الإختيار وتقوم 

Intent intent = new Intent();
intent.setType("video/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"Select Your Video"),REQUEST_TAKE_GALLERY_VIDEO);

public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (resultCode == RESULT_OK) {
            if (requestCode == REQUEST_TAKE_GALLERY_VIDEO) {
                Uri selectedImageUri = data.getData();

                //Device FILE Manager
                filemanagerstring = selectedImageUri.getPath();

                // Path From GALLERY
                selectedImagePath = getPath(selectedImageUri);
                if (selectedImagePath != null) {

          // new Intent that holdes  selected path so we can use it in  VideoAvtivity class or 					whatever your class is

                    Intent intent = new Intent(Mainctivity.this,
                            VideoAvtivity.class);
                    intent.putExtra("path", selectedImagePath);
                    startActivity(intent);
                }
            }
        }
    }

    
    public String getPath(Uri uri) {
        String[] projection = { MediaStore.Video.Media.DATA };
        Cursor cursor = getContentResolver().query(uri, projection, null, null, null);
        if (cursor != null) {
            // NULLPOINTER IF CURSOR IS NULL
            //  FILE MANAGER FOR PICKING THE MEDIA
            int column_index = cursor
                    .getColumnIndexOrThrow(MediaStore.Video.Media.DATA);
            cursor.moveToFirst();
            return cursor.getString(column_index);
        } else
            return null;
    }
رابط هذا التعليق
شارك على الشبكات الإجتماعية

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...