Friday, 9 March 2018

Video Linking in your Android App

Hi All,

First you place one 'VideoView' from 'Images& Video" tab in layout toolbox

Then add this code in the onCreate() function.

Place a 3gp file in WWW folder of WAMP

-------------------------------------
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
VideoView videoView = (VideoView)findViewById(R.id.videoView1); 
// videoView.setVideoURI(Uri.parse(path));

videoView.setVideoPath("http://10.0.2.2/HUP.3gp");

videoView.start();   
}

---------------------------------------------
Give INTERNET permission in manifest.xml file

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.hupvideo"
    android:versionCode="1"
    android:versionName="1.0" >
     <uses-permission android:name="android.permission.INTERNET" />

    <uses-sdk
        android:minSdkVersion="19"
        android:targetSdkVersion="19" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

No comments:

Post a Comment