1

I'm facing a strange problem in my application . Media player is unable to play video from raw folder but it plays the same video from sdcard.

But if I take another video, it's easily played from the raw folder.

Thanks, Vikas

Code

mVideoView.setVideoURI(Uri.parse("android.resource://<package name>/raw/video1"));
mVideoView.setOnPreparedListener(this);
mVideoView.setOnCompletionListener(this); 
mVideoView.setMediaController(mediaController);
mediaController.setEnabled(true);
mVideoView.requestFocus();
mVideoView.start();
njzk2
  • 38,969
  • 7
  • 69
  • 107
vky
  • 105
  • 1
  • 2
  • 7
  • do you mean an external media player cannot play a video from within your application raw folder? try and copy it to a public folder. – njzk2 Feb 29 '12 at 09:33
  • 1
    no i have some some video and I reside in raw folder but when I am trying to play these video via video view (MideaPlayer) it gives error but when I put same video in sdcard and set videopath() then it playing – vky Feb 29 '12 at 10:06
  • you just have something wrong in your code. post it. – josephus Feb 29 '12 at 10:14
  • hmm actually I have used same code for both only difference is its path. but for your convenient here is the code:: `mVideoView.setVideoURI(Uri.parse("android.resource:///raw/video1")); mVideoView.setOnPreparedListener(this); mVideoView.setOnCompletionListener(this); mVideoView.setMediaController(mediaController); mediaController.setEnabled(true); mVideoView.requestFocus(); mVideoView.start(); ` – vky Feb 29 '12 at 10:24
  • Do you means that the same video is not playing from raw folder but its playing from sdcard?? There is the problem in the URI mVideoView.setVideoURI(Uri.parse("android.resource:///+R.raw.video_name")) . – Om Narain Shukla Feb 29 '12 at 09:41
  • yes same video is not playing from raw. – vky Feb 29 '12 at 10:01
  • I understand can you make available this video file or some part of code for us.? – Om Narain Shukla Feb 29 '12 at 10:10
  • @vky : did you used this Uri.parse("android.resource:///+R.raw.video_name") this URI?? – Om Narain Shukla Mar 01 '12 at 06:16
  • yes I tried with both uri 1)Uri.parse("android.resource:///raw/video1") 2)Uri.parse("android.resource:///+R.raw.video_name") – vky Mar 01 '12 at 06:21

1 Answers1

2

See this question :

Playing .MP4 video from raw resource folder

As it appears, the Uri should contain the id (R.raw._your_video_) rather than the file name

Uri uri = Uri.parse("android.resource://[package]/"+R.raw.[video_resid]);
Community
  • 1
  • 1
njzk2
  • 38,969
  • 7
  • 69
  • 107
  • I tried but same error.. 02-29 16:10:17.554: E/MediaPlayer(6351): Unable to to create media player 02-29 16:10:17.554: D/MediaPlayer(6351): Couldn't open file on client side, trying server side 02-29 16:10:17.558: E/MediaPlayer(6351): error (1, -2147483648) 02-29 16:10:17.613: E/MediaPlayer(6351): Error (1,-2147483648) 02-29 16:10:17.613: D/VideoView(6351): Error: 1,-2147483648 – vky Feb 29 '12 at 10:42
  • also I tried with other video so it gives 02-29 16:13:26.542: W/AudioSystem(6351): AudioFlinger server died! 02-29 16:13:26.542: W/IMediaDeathNotifier(6351): media server died 02-29 16:13:26.542: E/MediaPlayer(6351): error (100, 0) 02-29 16:13:26.542: E/MediaPlayer(6351): Error (100,0) 02-29 16:13:26.542: D/VideoView(6351): Error: 100,0 – vky Feb 29 '12 at 10:44
  • Just to be sure, you did replace [package] by the actual package name declared in the manifest, right? – njzk2 Feb 29 '12 at 16:23
  • yes package is same and one thing more when I put same video in internal memory and use this path "/data/data//files/video.mp4" it also played the video. – vky Mar 01 '12 at 04:58