Android - What does MEDIA ERROR UNKNOWN -1 ussually means - android

I'm developing an Audio Player (using the MediaPlayer) which works fine on mdpi, hdpi, tablets, but throws a error: MEDIA ERROR UNKNOWN -1 on Samsung Galaxy mini (ldpi).
What I noticed is that this error occurs for majority of songs, though there are 1, 2 songs that still plays on Galaxy Mini.
Why does this error usually occurs?

I managed to know what was the problem by passing the same URI that was causing the issue to the native Audio Player and let see how it will react. The native audio player responded in a more user-friendly way, by saying that the file type is not supported.
So at least now I know the problem is not from my side.
private void startNativeAudioPlayer() {
String path="http://..";
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(path), "audio/*");
startActivity(intent);
}

Related

Cannot play default notification ringtone on some device

Here is my code snippet to play ringtone notification:
Uri u = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Ringtone r = RingtoneManager.getRingtone(MainActivity.this, u);
r.play();
This seems to work fine on most devices. However, on some devices such as Samsung S8 and Samsung S9, it does not work. Logcat shows:
I/Ringtone: Internal uri : content://settings/system/notification_sound
D/RingtoneManager: getActualDefaultRingtoneUri type :2
W/MediaPlayer: Couldn't open content://0#settings/system/notification_sound_cache:
java.io.FileNotFoundException: open failed: ENOENT (No such file or directory)
Note that the same code works fine on Samsung S7.
Wondering if anyone has any insight.

How to limit duration of MediaStore in Android 7

What's new with duration limit of MediaStore in Android 7? There is nothing about it in documentation, but since sdk version 24 a device records a video without any limit.
final Activity activity = (Activity) context;
String controlId = videoInput.getControlId();
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
if (videoInput.getMaxDuration() > 0) {
intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, videoInput.getMaxDuration());
}
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, videoInput.getRecordQuality().ordinal());
int requestCode = ActivityResultBus.getInstance().generateRequestCode(new SBundle(controlId));
activity.startActivityForResult(intent, requestCode);
I tested it on a real Motorola Nexus 6 with Android 7.0 and on virtual devices with 7.0 and 7.1.1. On previous versions all works as I want.
Mb something wrong with my extras bundle?
"There is no requirement for any camera app to honor EXTRA_DURATION_LIMIT. This is a request, not a command"
Any other way to limit the length of video ?
Not when you delegate the work to a third-party app. You are welcome to use the camera APIs and record the video directly yourself. Or, if your concern is not with the video on the device but some subset that you need to upload, look into how you can chop off the first 10 seconds of the video, and upload that piece.
This answer is directly compiled from this question : MediaStore.EXTRA_DURATION_LIMIT Not working Nexus Devices?

URl not played in android MediaPlayer

I'm working media palyer app, in this i need to stream audio from URL. In my case some URL's are not streamed in some devices (Eg. Samsung Note III), after a long time i got this error message in onError() method.
E/MediaPlayer(24445): error (1, -1004)
I used the following code to pay url.
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setDataSource(songPreViewUrl);
mediaPlayer.setOnPreparedListener(BackgroundAudioService.this);
mediaPlayer.setOnCompletionListener(BackgroundAudioService.this);
mediaPlayer.setOnBufferingUpdateListener(BackgroundAudioService.this);
mediaPlayer.prepareAsync();
Can any one please share the suggestion, why the urls are not streams in Samsung devices.

RTSP 1080p live-streaming android client gets error (100,0)

My new surveillance camera just arrived, so I'm trying to write an app to live stream the video from it.
Since it came with basically no documentation, I installed the 'onvifer' android app which allows you to browse the camera's capabilities. This app works fine - gets the video and allows PTZ controls, etc. It reports the streaming url as:
rtsp://192.1.0.193:554/mpeg4
I tested the stream in the VLC windows client, and it's able to stream video from that URL as well. This makes me comfortable that the network is working OK.
The camera states the feed will be 1920x1080; VLC confirms this.
The basic code in my activity:
VideoView videoView = (VideoView)this.findViewById(R.id.VideoView);
videoView.setVideoURI(Uri.parse("rtsp://192.1.0.193:554/mpeg4"));
videoView.requestFocus();
videoView.start();
I've also given the app INTERNET permissions in AndroidManifest.xml, disabled authentication on the camera, and am running on a real device (not the emulator).
When I run the app, LogCat shows this immediately:
setDataSource IOException happend :
java.io.FileNotFoundException: No content provider: rtsp://192.1.0.193:554/mpeg4
at android.content.ContentResolver.openTypedAssetFileDescriptor (ContentResolver.java).
About 15 seconds later, the app shows a "Can't play this video" modal dialog box and this is added to LogCat:
MediaPlayer error (100, 0)
AudioSystem AudioFlinger server died!
MediaPlayer error (100, 0)
VideoView Error: 100,0
I've googled everything I can think of, but haven't found anything useful.
Any thoughts?
wild-ass-guess on your logcat and the RC=100... No SDP file or no equivalent for RTSP of the 'moov atom' block required to negotiate details of the stream /container/ codec/ format... You can get the AOSP code for mediaPlayer/videoView and grep the RC value in the source.
RTSP is gnarly to debug ( note the tools links ) and not assured to run inside a NAT'd network due to UDP issues. So, to get better result, you may have to look into forcing your config to do data channel on TCP an not UDP. Or it could be other issues , of which there are many.
If you really want to investigate, some possible tools below:
Use command line and CURL client to request your stream:
Android - Java RTSP Session Mgmt package on Git
Protocol dumps for CLI RTSP sessions to Youtube RTSP/SDP streams
To pursue the issue, you may need to get into the weeds with debug tools that track details of the protocol negotiation that preceeds the MediaPlayer actually starting play on the stream. That would include learning the RFP and the protocol details.
videoView.setVideoURI(“rtsp://192.1.0.193:554/mpeg4”);
Try your app on another phone.
You may find the problem is about the mobile device.
Try this
path:"rtsp://218.204.223.237:554/mobile/1/4C024DFE77DC717D/onnuvesj43xj7t26.sdp".
See whether the code has something wrong.

Streaming m3u8 HLS Audio on Android

i've found problems trying to reproduce m3u8 HLS audio streaming on Android. Right now i can reproduce video in m3u8 HLS link with:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(Uri.parse(contentURL),"video/mp4");
startActivityForResult(i,0)
I've already tried this method:
number 1:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(Uri.parse(contentURL),"video/mp4");
startActivityForResult(i,0)
number 2:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(Uri.parse(contentURL),"audio/mp3");
startActivityForResult(i,0)
number 3:
MediaPlayer mediaPlayer = MediaPlayer.create(this, Uri.parse("http:\\testexample.m3u8"));
mediaPlayer.start();
In case 3 the error on log like "mediaserver Died", in case 1 and 2 simply the phone gallery said "can't reproduce video" or "can't reproduce this kind of file".
Last but not the least, if i send the http m3u8 link with an email at a Nexus 4 with Android 4.3, it open the link with chrome, then ask to open phone galleryplayer, and reproduce it. The same thing done with da SII with cyanogenmod and android 4.2.1 said, as before, "cannot reproduce video".
Put your code In try-catch block.
Set onPreparedListenet() and prepareAsync(), then on the onPrepared() callback start playback.

Categories

Resources