Skip to content

Instantly share code, notes, and snippets.

@Evin1-
Last active March 21, 2017 03:28
Show Gist options
  • Save Evin1-/4def299e1e943a91239079469334d078 to your computer and use it in GitHub Desktop.
Save Evin1-/4def299e1e943a91239079469334d078 to your computer and use it in GitHub Desktop.
Minimal VideoView
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="16dp"
android:orientation="vertical"
tools:context="com.example.myapplication.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
<VideoView
android:id="@+id/a_main_video"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<uses-permission android:name="android.permission.INTERNET" />
public class MainActivity extends AppCompatActivity {
private static final String VIDEO_URL = "http://techslides.com/demos/sample-videos/small.mp4";
private VideoView videoView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
videoView = (VideoView) findViewById(R.id.a_main_video);
videoView.setVideoURI(Uri.parse(VIDEO_URL));
videoView.start();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment