Ivan Kravchuk
Ivan Kravchuk

Reputation: 63

How to solve MediaPlayer Error "Can't play this video"

I had a problem with my videoview.

When I try play video from specific URL at my API-27 emulator Android show me message dialog

Can't play this video

That's it what I get in Logcat

source returned error -1010, 0 retries left

initFromDataSource, source has no track!

Failed to init from data source!

MediaPlayerNative: error (1, -2147483648)

MediaPlayer: Error (1,-2147483648)


That's my code where I use my videoview

mVideoView = findViewById(R.id.videoView);
        mMediaController = new MediaController(this);
        mVideoView.setVideoPath("https://clips.vorwaerts-gmbh.de/VfE_html5.mp4");
        mVideoView.requestFocus();
        initListeners();

initListeners method

mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mp) {
                mVideoView.setMediaController(mMediaController);
                mVideoView.setBackground(null);
                mMediaController.setAnchorView(mVideoView);
                mMediaController.show();
                mVideoView.start();
            }
        });
        mVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer mp) {
mVideoView.setBackground(getDrawable(R.drawable.webinar_photo_preview));
            }
        });

I test my videoview feature at api23, api24 and everything sounds good. Can somebody tell me what I'm doing wrong?

EDITED: Now I found that the error also appears on api24

Upvotes: 3

Views: 1582

Answers (2)

Ivan Kravchuk
Ivan Kravchuk

Reputation: 63

Problem was in VideoView, setVideoPath set videos only with little file size (1 - 2 MB) and if it size is bigger MediaPlayer crashes with MEDIA_ERROR_SYSTEM (-2147483648) - (low-level system error), read in documentation . That why I start using exoPlayer.

Upvotes: 3

Porush Manjhi
Porush Manjhi

Reputation: 164

Its look like your code is working fine and maybe the problem is that you are not using cookies that are send to browser at the time of request.

In simple terms this video is not for direct access via code.

If you still wants to try the steps below.

  1. Make http request to link (https://clips.vorwaerts-gmbh.de/VfE_html5.mp4) and store the received cookies.
  2. Use the received cookies with your next request when you want to play the video.

Note - If you want to use cookies to play video it can be done via ExoPlayer(https://github.com/google/ExoPlayer).

Upvotes: 0

Related Questions