1

I am developing a school application and I want to play video from my PHP server

I have tried this code but it couldn't play

Uri video = Uri.fromFile(myurl); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY); intent.setDataAndType(video, "video/*");

Dhasneem
  • 4,037
  • 4
  • 33
  • 47
Karan Mavadhiya
  • 1,042
  • 8
  • 23

2 Answers2

2

try this one, play the video on vedio view through the parse the uri

xml part

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

    <VideoView
        android:id="@+id/surface_view"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_gravity="center"
        />
</FrameLayout>

Now java part

 public class HelloInterruptVideoStream extends Activity
{
    private String path = "http://dl.dropbox.com/u/145894/t/rabbits.3gp";
    private VideoView videoview;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        videoview = (VideoView)findViewById(R.id.surface_view);

        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
           getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

        videoview.setVideoURI(Uri.parse(path));
        videoview.setMediaController(new MediaController(this));
        videoview.requestFocus();
        videoview.start();
    }
}

Use internet permission in menifest file

<uses-permission android:name="android.permission.INTERNET"/>
Sunil Kumar
  • 7,086
  • 4
  • 32
  • 50
  • i do the same thing but i got 08-12 15:02:53.424: D/MediaPlayer(7164): Couldn't open file on client side, trying server side 08-12 15:02:55.639: E/MediaPlayer(7164): error (1, -2147483648) 08-12 15:02:55.640: E/MediaPlayer(7164): Error (1,-2147483648) 08-12 15:02:55.640: D/VideoView(7164): Error: 1,-2147483648 error – Vaishali Sutariya Aug 12 '14 at 09:34
0

Try to set your MediaController in this way:

MediaController mediaController= new MediaController(this);

mediaController.setAnchorView(video);  
videoview.setMediaController(mediaController);
Kurt Van den Branden
  • 11,995
  • 10
  • 76
  • 85
Sumit Kumar
  • 564
  • 6
  • 14