E/MediaPlayerNative: error (1, -2147483648) - android

I have uploaded a video in my recourses file in android studio and I want to play the video offline in my app my video is of 1 MB but when I run my app it throws an error
error (1, -2147483648)
and a pop up
shows up that Video can not be played.
E/SurfaceSyncer: Failed to find sync for id=0
E/MediaPlayerNative: error (1, -2147483648)
W/Parcel: Expecting binder but got null!
E/MediaPlayer: Error (1, -2147483648)
D/VideoView: Error: 1,-2147483648
This is my Main class code
package com.example.igea;
import...
public class MathsChap1 extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maths_chap1);
Button bb = findViewById(R.id.ibk);
bb.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent i = new Intent( packageContext: MathsChap1.this, Maths.class);
startActivity(i);
}
});
VideoView v1 = findViewById(R.id.vv1);
v1.setVideoPath("android.resources://" + getPackageName() + "/" + R.raw.video1);
MediaController mc = new MediaController( context: this);
v1.setMediaController(mc);
mc.setAnchorView(v1);
v1.start();
}
}
Can someone please help me with this error?

You can use MediaPlayer
MediaPlayer mediaPlayer;
mediaPlayer = MediaPlayer.create(this, R.raw.your_video_file);
mediaPlayer.start();

Related

Media player stops working after playing some files

I have an Android app and I want to play different sounds. My code works fine but after playing some sounds it stops playing more sounds.
My click listener is in a ListView, So it loops for different sounds.
I think the problem is because of creating and stoping, but I don't understand how to fix it?
Can anyone please help with my code?
MediaPlayer mp;
holder.alphabetSound.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if(mp != null && mp.isPlaying()) {
mp.stop();
}
mp = MediaPlayer.create(activity,sound[index]));
mp.start();
}
});
Logcat:
2019-10-26 20:44:28.737 1319-8893/? E/MP3Extractor: Unable to resync. Signalling end of stream.
2019-10-26 20:44:28.744 1315-1946/? E/OMXNodeInstance: setConfig(52300a9:google.mp3.decoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
2019-10-26 20:44:28.751 1306-9450/? E/AudioFlinger: no more track names available
2019-10-26 20:44:28.751 1306-9450/? E/AudioFlinger: createTrack_l() initCheck failed -12; no control block?
2019-10-26 20:44:28.751 1320-10055/? E/AudioTrack: AudioFlinger could not create track, status: -12
2019-10-26 20:44:28.751 1320-10055/? E/AudioSink: Unable to create audio track
2019-10-26 20:44:28.752 1320-10052/? E/NuPlayer: received error(0xffffffed) from audio decoder, flushing(0), now shutting down
2019-10-26 20:44:28.752 9789-9801/ir.lariha.englishanimals E/MediaPlayer: error (1, -19)
2019-10-26 20:44:28.752 9789-9789/ir.lariha.englishanimals E/MediaPlayer: Error (1,-19)
private void startMP(final Context context){
if(mp == null){
mp = MediaPlayer.create( context, R.raw.ringtone);
mp.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
#Override
public void onCompletion(MediaPlayer mediaPlayer) {
stopMP(context);
}
});
}
mp.start();
mp.setLooping(true);
}
private void stopMP(Context context) {
if(mp != null) {
mp.release();
mp = null;
Toast.makeText(context , "song is stopped " , Toast.LENGTH_SHORT).show();
}
}
use this methods by your own necessity.
As you think ,problem is in your creating and stopping procedure. I think if you follow that , it would be helpful.

Android : Error E/MediaPlayer: setDataSource: IOException! when try to View video

i faced some problems when try to view video using VideoView. i always got message Can't play this video after that appears failed to connect
This is my url
rtsp://136.243.10.198:1935/xxx_vod/xx_1455171793.mp4?key=b1fbf3e6e6edcc2bb6c75f879edf8bf0
i got error on Log :
E/MediaPlayer: setDataSource: IOException! uri=rtsp://136.243.10.198:1935/xxx_vod/xx_1455171793.mp4?key=b1fbf3e6e6edcc2bb6c75f879edf8bf0
and
E/MediaPlayer: error (262, -1010)
My Code :
path = getActivity().getIntent().getStringExtra("path");
videoView.setMediaController(new MediaController(getActivity()));
videoView.setVideoPath(path);
videoView.requestFocus();
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer mediaPlayer) {
mediaPlayer.start();
}
});

Can't play this video

When i want to play video from sdcard can't play this video error is shown
the code is
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
VideoView vv = (VideoView) findViewById(R.id.videoView);
vv.setVideoPath("/sdcard/idayam.mp4");
vv.setMediaController(new MediaController(this));
vv.start();
vv.requestFocus();
}
}and my LogCat error is
07-28 16:52:26.874: E/MediaPlayer(23466): error (1, -2147483648)
Change
vv.setVideoPath("/sdcard/idayam.mp4");
to
vv.setVideoPath(Environment.getExternalStorageDirectory().getAbsolutePath() + "/idayam.mp4");
The path that you are providing is not a valid one. You should always use Environment.getExternalStorageDirectory().getAbsolutePath() to get the path of the SD card

android video from local server error

Hi there I'm working in my android app to run video from my local server XAMPP and I have placed my video in htdocs folder under my XAMPP server folder and I got this piece of code :
this is the .java file code
public class video extends Activity {
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.video1);
final VideoView vv = (VideoView) findViewById(R.id.vview);
MediaController mc = new MediaController(this);
vv.setMediaController(new MediaController(this));
vv.setVideoURI(Uri.parse("http://10.0.2.2/abc.MP4"));
vv.requestFocus();
vv.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
vv.start();
}
});
}
}
and here's my logcat errors
03-02 02:12:29.222: E/MediaPlayer(464): error (1, -2147483648)
03-02 02:12:29.242: E/MediaPlayer(464): start called in state 0
03-02 02:12:29.242: E/MediaPlayer(464): error (-38, 0)
03-02 02:12:29.252: E/MediaPlayer(464): Attempt to call getDuration without a valid mediaplayer
03-02 02:12:29.252: E/MediaPlayer(464): error (-38, 0)
03-02 02:12:29.322: E/MediaPlayer(464): Error (1,-2147483648)
03-02 02:12:29.742: E/MediaPlayer(464): Error (-38,0)
03-02 02:12:30.222: E/MediaPlayer(464): Error (-38,0)
When I click the button to direct me to video view layout where I should see my video playing I got a "black" blank screen for a moment then the screen changes to a white color for the lower have and black for the upper after that I receive the "this video can't be played" error msg three of them together

Media Player error when playing Video in Emulator

I'm trying to play video from youtube using this code but I get this error from my log cat:
06-28 16:23:09.794: E/MediaPlayer(621): error (1, -2147483648)
Here is my code:
public class PromoActivity extends Activity{
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(com.frux.kfcmobile.R.layout.promo);
VideoView videoView = (VideoView)this.findViewById(com.frux.kfcmobile.R.id.videoView);
String path = "rtsp://v4.cache5.c.youtube.com/CjYLENy73wIaLQmofK96HM6gyhMYDSANFEIJbXYtZ29vZ2xlSARSBWluZGV4YJWAl-O04anmTww=/0/0/0/video.3gp";
Uri vid = Uri.parse(path);
videoView.setVideoURI(vid);
videoView.setMediaController(new MediaController(this));
videoView.start();
videoView.requestFocus();
}
}
Can anyone help me?
Try this code
video.setVideoURI(Uri
.parse("rtsp://v6.cache7.c.youtube.com/CiILENy73wIaGQk-fYZWNAPDsxMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp"));
mMediaController = new MediaController(this);
mMediaController.setMediaPlayer(video);
video.start();
And you try to run in Device.. Because in emulator only some videos will get played.

Categories

Resources