0

When I try to play a video in my Android application, I receive the message "Can't play this video". My activity with the VideoView:

package midamcorp.com.burgerkingapp;

import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageButton;
import android.widget.VideoView;

import java.net.URI;

public class videoViewer extends AppCompatActivity {
VideoView vidView;
    ImageButton back;
    final String path = "www.midamcorp.com";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video_viewer);

        vidView = (VideoView) findViewById(R.id.videoView);
        back = (ImageButton) findViewById(R.id.backButton);


        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

Intent i = getIntent();
        String vidPath = i.getStringExtra("path");
       try {
           Uri.Builder builder = new Uri.Builder();
           builder.scheme("http");
           builder.authority(path);
           builder.appendPath("videos");
           builder.appendPath(vidPath);

           Uri uri = builder.build();
           Log.i("Uri is ", uri.toString());
           vidView.setVideoURI(uri);

           vidView.start();
       } catch (Exception e) {
           Log.e(this.getClass().toString(), "error with URI");
       }



    }
}

Some of the output

05-11 08:30:05.022 21669-21669/midamcorp.com.burgerkingapp I/Uri is: http://www.midamcorp.com/videos/whopperDog.wmv
05-11 08:30:05.163 21669-21669/midamcorp.com.burgerkingapp W/MediaPlayer: Couldn't open file on client side; trying server side: java.io.FileNotFoundException: No content provider: http://www.midamcorp.com/videos/whopperDog.wmv

Whenever I navigate to the video path in my browser, it downloads rather than plays, but I had thought this might be related to the browser settings. Could this relate to the issue? I would truly appreciate any help.

KellyM
  • 2,472
  • 6
  • 46
  • 90

2 Answers2

0

You are not setting MediaController Just try it..

MediaController mediacontroller = new MediaController(
                       mContext);
                mediacontroller.setAnchorView(vidView );
                // Get the URL from String VideoURL
                Uri video = Uri.parse(vidPath);
                vidView .setMediaController(mediacontroller);
                vidView .setVideoURI(video);
Mahesh Giri
  • 1,810
  • 19
  • 27
0

Have you tried an avi or mp4 file? I do not think Android supports wmv files in video view.

See this answer Android Media Player Library

http://developer.android.com/guide/appendix/media-formats.html

Community
  • 1
  • 1
agomes
  • 331
  • 2
  • 8
  • Thanks, but it still does not work. I tried adding a media controller and using avi video but got the following: 05-11 09:09:53.370 6736-6736/midamcorp.com.burgerkingapp I/Uri is: http://www.midamcorp.com/videos/whopperDog.avi 05-11 09:09:53.482 6736-6736/midamcorp.com.burgerkingapp W/MediaPlayer: Couldn't open file on client side; trying server side: java.io.FileNotFoundException: No content provider: http://www.midamcorp.com/videos/whopperDog.avi 05-11 09:09:53.861 6736-6748/midamcorp.com.burgerkingapp E/MediaPlayer: error (1, -2147483648) – KellyM May 11 '16 at 14:11