Opening RTSP video in VideoView - android

I wan't to open a .3gp video that is hosted on a remote server in a VideoView inside my app. The protocol used is RTSP. I keep getting this error:
04-07 19:26:32.528: E/MediaPlayer(7358): Unable to to create media player
04-07 19:26:32.536: W/VideoView(7358): Unable to open content: rtsp://v2.cache1.c.youtube.com/CiULENy73wIaHAk-BOiQ3AO9gBMYDSANFEgGUglwbGF5bGlzdHMM/0/0/0/video.3gp
04-07 19:26:32.536: W/VideoView(7358): java.io.IOException: setDataSource failed.: status=0x80000000
The stream is working and the codec should be supported. Can't locate the problem. I've tried it on a Sony GTV box and on a ICS tablet.
This is the code I'm using:
videoview.setVideoURI(Uri.parse(viduri));
MediaController mc = new MediaController(PlayerActivity.this);
videoview.setMediaController(mc);
videoview.requestFocus();
videoview.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
public void onPrepared(MediaPlayer arg0) {
progressBar.setVisibility(View.GONE);
videoview.start();
}
});
Does anyone have experience with the same issue? Any solutions? The error message isn't very helpful...

What I see is that this stream can't be found. Are you obtaining this Youtube video using YouTube Data API?

Related

Want to create app, to stream from a url in android

I get a Url from anyone in this format:
http://ak...
There is a video wich plays with flashplayer.
I want to stream this video from a android app and I tried it with videoview and mediacontroller. But it's not working and I don't know what to do anymore.
Can you give me some keywords to solve the problem, so I could search on the internet for it.
try {
String videoUrl= "http://ak;
// Start the MediaController
MediaController mediacontroller = new MediaController(
LiveStreamActivity.this);
mediacontroller.setAnchorView(videoview);
// Get the URL from String VideoURL
Uri video = Uri.parse(videoUrl);
videoview.setMediaController(mediacontroller);
videoview.setVideoURI(video);
startTimer();
} catch (Exception e) {
e.printStackTrace();
}
videoview.requestFocus();
videoview.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
// Close the progress bar and play the video
#Override
public void onPrepared(MediaPlayer mp) {
videoview.start();
checkBuffering();
}
});
This is my code and the logcat is:
I/MediaPlayer: path is null
D/MediaPlayer: setDataSource IOException happend :
java.io.FileNotFoundException: No content provider: http://ak-rt01.mni.thm.de:3000/#/playlist/57b03967e4da719c28d9fe2d
at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1052)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:907)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:834)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:987)
at android.widget.VideoView.openVideo(VideoView.java:337)
at android.widget.VideoView.access$2100(VideoView.java:71)
at android.widget.VideoView$7.surfaceCreated(VideoView.java:617)
at android.view.SurfaceView.updateWindow(SurfaceView.java:601)
at android.view.SurfaceView.access$000(SurfaceView.java:94)
at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:183)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:879)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2129)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1234)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6465)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:803)
at android.view.Choreographer.doCallbacks(Choreographer.java:603)
at android.view.Choreographer.doFrame(Choreographer.java:573)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:789)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5356)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(Native Method)
D/MediaPlayer: Couldn't open file on client side, trying server side
V/MediaPlayer: setVideoSurfaceTexture
V/MediaPlayer-JNI: setAudioStreamType: 3
V/MediaPlayer: MediaPlayer::setAudioStreamType
V/MediaPlayer: setVideoSurfaceTexture
V/MediaPlayer: prepareAsync
D/ProgressBar: setProgressDrawable drawableHeight = 48
D/AbsSeekBar: AbsSeekBar Constructor: misSeebarAnimationAvailable = true
V/MediaPlayer: message received msg=100, ext1=1, ext2=-1004
E/MediaPlayer: error (1, -1004)
V/MediaPlayer: callback application
V/MediaPlayer: back from callback
E/MediaPlayer: Error (1,-1004)
D/VideoView: Error: 1,-1004
The problem that your media controller is experiencing is that its not able to find a valid video file from the URL. The Video URI for VideoView should be of usually this format http://dummyWebSite/dummy/randomFile.mp4 or http://blah/blah/File.avi . Notice here that the path to the randomFile.mp4 video file uploaded on server is given over here.
For testing purposes, you can use this URL and try the same code by replacing your url with this (valid URL with a mp4 file) http://techslides.com/demos/sample-videos/small.mp4
So what could be some alternatives to this?
ALTERNATIVE 1 (best solution)
Upload your video mp4, mov or avi on a file server and hit the url of your video on the file server.
ALTERNATIVE 2
Open the given link in the android device web browser.
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://ak-rt01.mni.thm.de:3000/#/playlist/57b03967e4da719c28d9fe2d"));
startActivity(intent);
ALTERNATIVE 3
Open the link in the android WebView
<WebView
android:id="#+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
WebView webView= (WebView) findViewById(R.id.webView);
webView.loadUrl("http://ak-rt01.mni.thm.de:3000/#/playlist/57b03967e4da719c28d9fe2d");
short version :
instead of...
String videoUrl= "http://ak-rt01.mni.thm.de:3000/#/playlist/57b03967e4da719c28d9fe2d";
try using...
String videoUrl= "http://ak-rt01.mni.thm.de:3000/storage/playliststorage/57b03967e4da719c28d9fe2d/mainpanel/m1.m3u8";
long version :
"I want to stream this video from an Android app and I tried it with videoview and mediacontroller. But it's not working..."
Your videoUrl (http://ak-rt01.mni.thm.de:3000/#/playlist/57b03967e4da719c28d9fe2d) is actually accessing a .m3u8 playlist file. This list has streams of different video resolutions and you must load the relevant resolution's own .m3u8 for a playlist of .ts video files.
So try the following :
(1) : Load the streams.m3u8 as text (later can use String functions to extract relevant stream link)
http://ak-rt01.mni.thm.de:3000/storage/playliststorage/57b03967e4da719c28d9fe2d/mainpanel/streams.m3u8
and it will look like this :
#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=720896,RESOLUTION=426x240
m1.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1048576,RESOLUTION=640x360
m2.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1376256,RESOLUTION=853x480
m3.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2031616,RESOLUTION=1024x576
m4.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2686976,RESOLUTION=1280x720
m5.m3u8
So from the above text we can deduce that 240p video is linked to m1.m3u8, or that 480p video is linked to m3.m3u8 and so on...
(2) : Suppose you want to play 240p (426 x 240) that will be m1.m3u8 so the link is :
http://ak-rt01.mni.thm.de:3000/storage/playliststorage/57b03967e4da719c28d9fe2d/mainpanel/m1.m3u8
For any other streams just replace the m1 part of above link with either m2, m3, m4, or m5.
(3) : Playing it Android... This is the tricky part for me to advise because I use Flash more to make my Android .apk apps (actually I'm here because you tagged Flash). You need to find the right Android SDK code examle for playing an m3u8 file.
You need to investigate : how to play m3u8 file in Android SDK
As a starting point try this possible solution. That code with your 240p looks like :
VideoView videoview = (VideoView)findViewById(R.id.myvideoview);
videoview.setMediaController(new MediaController(this));
videoview.setVideoURI(Uri.parse("http://ak-rt01.mni.thm.de:3000/storage/playliststorage/57b03967e4da719c28d9fe2d/mainpanel/m1.m3u8"));
videoview.requestFocus();
videoview.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
mp.start();
}
});
Another possible solution: link 1. All I can tell you is that Android can handle .ts video files and will accept a valid m3u8 URL.

Android VideoView not working in sdk 4.3

I am trying to play a video from the device on a VideoView. Here is my code:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
vView = (VideoView) findViewById(R.id.videoView);
mc = new MediaController(this);
vView.setMediaController(mc);
String new_emulator_path = "/storage/emulated/0/Download/testvid.mp4";
Uri uri = Uri.parse(new_emulator_path);
vView.setVideoURI(uri);
vView.requestFocus();
mc.show();
vView.start();
}
...
<VideoView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/videoView"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:adjustViewBounds="true" />
While using the same code on 5.1 it plays fine, but does not play in 4.3 and below. Following is the log extract:
04-30 00:28:09.141 2293-2293/com.ebook.video D/MediaPlayer: getMetadata
04-30 00:28:09.249 2293-2314/com.ebook.video E/MediaPlayer: error (1, -2147483648)
04-30 00:28:09.257 2293-2293/com.ebook.video E/MediaPlayer: Error (1,-2147483648)
04-30 00:28:09.257 2293-2293/com.ebook.video D/VideoView: Error: 1,-2147483648
I have seen many threads in regard to this error code, but could not comprehend any explanations.
EDIT: I have tried playing videos of different formats - mkv (H264 mpeg-4 AVC) , 3gp (H263), mp4 (H264 mpeg-4 AVC), flv (FLV1). Video with 3gp extension and H263 format plays fine, while others give the error message as mentioned above. Any ideas on how to resolve this ?
According to Documentation Android not support H265 before android 5.1
So I think you have issue with this. You can use ExoPlayer (Or better way ExoMedia simple wrapper around VideoPlayer & ExoPlayer).
BTW use following piece of code may helps you :
VideoView videoView = (VideoView) findViewById(R.id.videoView1);
videoView.setVideoPath(YOUR_LOCAL_FILE_PATH);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
videoView.setMediaController(mediaController);
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer mp) {
Log.i(TAG,"Hoooray");
}
});
videoView.start();
As I found out from your code you want to display video in emulator so first see this related post.

Error : avformat_open_input: Protocol not found : -1330794744

I am building an android stream player using Vitamio.
Here is my codes:
mVideoView = (VideoView) findViewById(R.id.videoView);
path = "https://www.youtube.com/watch?v=vic5gj2qXKg";
mVideoView.setVideoPath(path);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer mediaPlayer) {
mediaPlayer.setPlaybackSpeed(1.0f);
}
});
But it returns ERROR:
avformat_open_input: Protocol not found : -1330794744
error (1, -1330794744)
I think this error is related to FFMpeg for Vitamio.
Who can solve this problem?
Thank you.
It appears when ffmpeg does not support streaming format, or not initialized by "avformat_network_init()"
See if you can find whether Vitamio supports network format or not, or some function to initialize.
Youtube videos links can be play via only Youtube Android Player API. Download Jar from here: https://developers.google.com/youtube/android/player/downloads/

Android Sorry, this video cannot be played

I'm using VideoPlayer in my app. It play everything fine but when I want to scroll on the media player's bar, usually it gives me the error : Sorry, this video cannot be played. and I have to restart the video to watch it again. All I found is if I stop the video and scroll the bar it will be fine. I just wonder how can I fix this problem ? how can I access to media player's bar. Hens I can pause the video onClick. My code:
MediaController mediaController = new MediaController(
rootView.getContext());
mediaController.setAnchorView(video);
Uri uri = Uri.parse(passVideo.file_link);
video.setMediaController(mediaController);
video.setVideoURI(uri);
video.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer arg0) {
mProgress.setVisibility(View.INVISIBLE);
video.requestFocus();
video.start();
}
});
Many people get this error like you,
Bugs :
Sorry this video is not valid for streaming to this device.
Sorry, this video can not be played.
You can find out at Sorry, this video is not valid for streaming to this device in Http streaming android
Thanks,

Google TV VideoView playing YouTube rtsp videos

I am accessing a video link via the YouTube API thusly:
JSONObject(videoString).getJSONObject("entry")
.getJSONObject("media$group").getJSONArray("media$content")
.getJSONObject(0).getString("url");
Which gives me a link to a video such as:
rtsp://v7.cache5.c.youtube.com/CiILENy73wIaGQlXg0iXvlQ9SBMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp
I then try to play the video with:
mVideoView.setVideoURI(result);
final MediaController mediaController = new MediaController(mActivity);
mVideoView.setMediaController(mediaController);
mVideoView.requestFocus();
mVideoView.start();
This works fine on my tablet running ICS but doesn't seem to work on GoogleTV, is there something I need to do specifically for GTV in this instance?
Logcat output:
04-30 14:03:41.212: D/MediaPlayer(1132): Couldn't open file on client side, trying server side
04-30 14:03:41.308: D/dalvikvm(1132): GC_CONCURRENT freed 862K, 13% free 8303K/9479K, paused 0ms+2ms
04-30 14:03:51.920: E/MediaPlayer(1132): error (1, -2147483648)
04-30 14:03:51.920: E/MediaPlayer(1132): Error (1,-2147483648)
04-30 14:03:51.920: D/VideoView(1132): Error: 1,-2147483648
I verified that VideoView playing YouTube RTSP video works on Google TV:
String vURL = "rtsp://v5.cache1.c.youtube.com/CjYLENy73wIaLQnhycnrJQ8qmRMYESARFEIJbXYtZ29vZ2xlSARSBXdhdGNoYPj_hYjnq6uUTQw=/0/0/0/video.3gp";
mVideoView = (VideoView)this.findViewById(R.id.myvideoview);
mVideoView.setVideoURI(Uri.parse(vURL));
final MediaController mediaController = new MediaController(this);
mVideoView.setMediaController(mediaController);
mVideoView.requestFocus();
mVideoView.start();
Only thing I changed was parsing a different URL. Try this working URL in your code then.

Categories

Resources