Reputation: 7
I have indeed tried to check here and else were for solution to this but no luck, probably because am a newbee.
TASK: I want to play a RTSP
video stream on an android app
TRIALS: I tried out with a 2min mp4
video copied to the res\raw
folder with Media Player and VideoView
. Later I used the API Demo
sample and I set:
path = "android.resourcee://com.me.mobile/R.raw.mithlat";
ERROR:
on MediaPlayer
API Demo just a blank page, no video no sound
on VideoView
API Demo it shows
"Sorry this video cannot be played"
CONFIG:
My target is 2.33
(This is what am testing with)
minimun is 2.1
Thank you
Upvotes: 0
Views: 4200
Reputation: 21
I know it a very late reply but for future references, I am adding this.
This is because path should be mentioned like this :
"android.resource://" + getPackageName() +"/raw/" + mediaName"
, where media name is the name of video sample.
R.raw.variableName/fileName
gives the int value references and should be with the Android's inbuilt functions like getString(R.id.string_name)
, which return the exact resources in required formats.
Also, in this case, VideoView
is not getting the proper media file that's why it is not able to run it and giving this error.
Upvotes: 1
Reputation: 11
Please try the following code for playing Video in the videoView
VideoView videoView = (VideoView)findViewById(R.id.VideoView);
Uri uri = Uri.parse("android.resource://" + getPackageName()+"/"+ R.raw.demo7);
video.setVideoURI(uri);
video.start();
Upvotes: 0
Reputation: 401
Video Streaming or Playing Video require too much power. Sometimes it will not play to emulator. try to Run it to your phone.
Try this code and Run this to your phone.
public void onCreate(Bundle savedInstanceState){
setContentView(R.layout.main);
String videourl = "http://something.com/blah.mp4";
Uri uri = Uri.parse(videourl);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.setDataAndType(uri, "video/mp4");
startActivity(intent);
}
Or Click here to watch Android Video Streaming Tutorial.
Upvotes: 2
Reputation: 3463
Try the stream rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov. Type this in your browser and it will automatically open with the android native player. If this plays then you probably need to look at your stream once again. I dont have android 2.3 although i played the same url in android 3.2 and it worked. Also check the answer of Playing a video in VideoView in Android for you reference. Hope this helps you I guess android 2.3 does not support rtsp
although not pretty sure. Try the url and check if it is playing
Upvotes: 0