Long-time user, first time poster. So thanks already to everyone who has helped on here, directly or indirectly before.
I'm having issues trying to stream an mp4/3gp video file which is being served over RTSP. The code for my POC is below, but is pretty much identical to the example I found here:
http://android-coding.blogspot.co.uk/2011/03/simple-example-using-videoview-to-play.html
String rtspLink = "rtsp://v5.cache1.c.youtube.com/CjYLENy73wIaLQnhycnrJQ8qmRMYESARFEIJbXYtZ29vZ2xlSARSBXdhdGNoYPj_hYjnq6uUTQw=/0/0/0/video.3gp";
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_vid_view_rtsp);
VideoView myVideoView = (VideoView)findViewById(R.id.myvideoview);
myVideoView.setVideoURI(Uri.parse(rtspLink));
myVideoView.setMediaController(new MediaController(this));
myVideoView.requestFocus();
myVideoView.start();
}
Unfortunately, most of the examples I found are from a few years ago, this one in particular being from 2011. I am testing on a physical Samsung S3 (Android 4.3).
I have confirmed that the 3gp file does exist, and have successfully streamed it using VLC. I have the same issue with my own MP4's.
The stack trace/logcat generated is as follows:
09-15 02:16:07.520 25040-25040/org.chutchut.videoviewrtsp D/MediaPlayer﹕ setDataSource IOException happend :
java.io.FileNotFoundException: No content provider: rtsp://v5.cache1.c.youtube.com/CjYLENy73wIaLQnhycnrJQ8qmRMYESARFEIJbXYtZ29vZ2xlSARSBXdhdGNoYPj_hYjnq6uUTQw=/0/0/0/video.3gp
at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:761)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:665)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:960)
at android.widget.VideoView.openVideo(VideoView.java:264)
at android.widget.VideoView.access$2000(VideoView.java:52)
at android.widget.VideoView$6.surfaceCreated(VideoView.java:522)
<.. snip ..>
09-15 02:16:07.520 25040-25040/org.chutchut.videoviewrtsp D/MediaPlayer﹕ Couldn't open file on client side, trying server side
09-15 02:16:07.530 25040-25040/org.chutchut.videoviewrtsp E/MediaPlayer﹕ Unable to to create media player
09-15 02:16:07.535 25040-25040/org.chutchut.videoviewrtsp W/VideoView﹕ Unable to open content: rtsp://v5.cache1.c.youtube.com/CjYLENy73wIaLQnhycnrJQ8qmRMYESARFEIJbXYtZ29vZ2xlSARSBXdhdGNoYPj_hYjnq6uUTQw=/0/0/0/video.3gp
java.io.IOException: setDataSource failed.: status=0x80000000
at android.media.MediaPlayer._setDataSource(Native Method)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1185)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1130)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:989)
at android.widget.VideoView.openVideo(VideoView.java:264)
at android.widget.VideoView.access$2000(VideoView.java:52)
at android.widget.VideoView$6.surfaceCreated(VideoView.java:522)
<.. snip ..>
09-15 02:16:07.535 25040-25040/org.chutchut.videoviewrtsp D/VideoView﹕ Error: 1,0
Thanks in advance!
Related
So I am trying to make a VideoView play a video with a link from Drive. I made the Network security configuration and the video can't be played still ("Your video can't be played.") I realized that the problem is not the code, but the link. I tried links from already made players and some work some not. I only want to make the video work. With either the drive link or another method. I am going to show you what I did. I would appreciate it if someone will help me .
The code:
VideoView videoView = findViewById(R.id.SY);
Uri uri = Uri.parse("https://drive.google.com/file/d/1CRJ8tL-DyjD0Nwd7ezkboGm6570zMf4C/view?usp=sharing");
videoView.setVideoURI(uri);
MediaController mc = new MyMediaController(videoView.getContext());
mc.setMediaPlayer(videoView);
videoView.setMediaController(mc);
videoView.start();
videoView.setOnCompletionListener(mp -> onBackPressed());
The network xml:
<network-security-config>
<domain-config>
<domain includeSubdomains="true">diligent_app.com</domain>
<trust-anchors>
<certificates src="system"/>
</trust-anchors>
</domain-config>
Manifest:
android:usesCleartextTraffic="true"
android:networkSecurityConfig="#xml/network"
What I got as an error
2021-08-30 14:53:35.338 4582-7140/? E/WindowManager: win=Window{4c93299
u0 com.example.diligent/com.diligent_app.diligent.yoga.Yoga}
destroySurfaces: appStopped=true win.mWindowRemovalAllowed=false
win.mRemoveOnExit=false win.mViewVisibility=8
caller=com.android.server.wm.ActivityRecord.destroySurfaces:5227
com.android.server.wm.ActivityRecord.destroySurfaces:5208
com.android.server.wm.ActivityRecord.notifyAppStopped:5267
com.android.server.wm.ActivityRecord.activityStopped:5894
com.android.server.wm.ActivityTaskManagerService.activityStopped:2584
android.app.IActivityTaskManager$Stub.onTransact:2215
android.os.Binder.execTransactInternal:1190
2021-08-30 14:53:35.605 4302-16264/? E/GenericSource: text/html from
getMIMEType()
2021-08-30 14:53:35.605 12855-15380/com.example.diligent
E/MediaPlayerNative: error (1, -1015)
2021-08-30 14:53:35.606 12855-12855/com.example.diligent E/MediaPlayer:
Error (1,-1015)
2021-08-30 14:53:37.695 4582-6879/? E/TaskPersister: File error
accessing recents directory (directory doesn't exist?).
2021-08-30 14:53:42.774 4582-4618/? E/BatteryStatsService: Unable to load
Power Hal or power.stats HAL
Thank you in advance.
The link with sharing in its URL will just take you to a web page (not video data).
For downloading the video data into your player, try as:
Uri uri = Uri.parse("https://drive.google.com/uc?export=download&id=1CRJ8tL-DyjD0Nwd7ezkboGm6570zMf4C");
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.
I'm trying to load video from my S3 AWS service.
The problem is that every time I try to load video, I'm getting:
D/MediaPlayer﹕ Couldn't open file on client side, trying server side
E/MediaPlayer﹕ error (1, -2147483648)
E/MediaPlayer﹕ Error (1,-2147483648)
D/VideoView﹕ Error: 1,-2147483648
I don't know if it's problem with permissions? This is my Android Code:
AWSCredentials myCredentials = new BasicAWSCredentials("my-key", "secret-key");
AmazonS3 s3client = new AmazonS3Client(myCredentials);
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest("-", "AndroidCommercial.3gp");
objectURL = s3client.generatePresignedUrl(request);
videoview = (VideoView) findViewById(R.id.videoView);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
MediaController mediaCtrl;
mediaCtrl = new MediaController( MainActivity.this );
mediaCtrl.setMediaPlayer(videoview);
videoview.setMediaController(mediaCtrl);
Uri clip = Uri.parse(String.valueOf(objectURL));
videoview.setVideoURI(clip);
videoview.requestFocus();
videoview.start();
I'm not sure if it's problem with AWS or my APP... I've created user with AmazonS3FullAccess policy. I can download that file with AWS chrome extension. Can anyone help me?
Best Regards, Mateusz
I am trying to open a video in a videoView using an url.
Here are the code i use:
public void playVideo(){
String path= "http://s3.amazonaws.com/yendis_development/uploads/container/content/4fd79353c83b7260e6000003/3.mpg";
String path1="http://commonsware.com/misc/test2.3gp";
Uri uri=Uri.parse(path);
VideoView video=(VideoView)findViewById(R.id.video_view);
video.setVideoURI(uri);
video.start();
}
When i use "path1", my VideoView get the video and play it fine.
but when i use "path", i don't get the video and i got a dialog saying "Sorry, this video cannot be played".
Why the webview worked for the path1 and not for path? You can open path and path1 in the navigator so you can see videos' test.
When path, In my logcat, i got this message (error):
08-11 17:08:47.411: E/MediaPlayer(10064): error (1, -2147483648)
08-11 17:08:47.411: E/MediaPlayer(10064): Error (1,-2147483648)
08-11 17:08:47.411: D/VideoView(10064): Error: 1,-2147483648
Thanks
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?