video view sample code android

Posted On // Leave a Comment
//manifest.xml

<activity
            android:name=".intro3"
            android:configChanges="orientation|keyboardHidden"
            android:label="@string/title_activity_intro3"
            android:parentActivityName=".MainActivity"
            android:screenOrientation="landscape"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="in.foxbrain.www.Facts.MainActivity" />
        </activity>





//.xml
<FrameLayout 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:background="#0099cc"
    tools:context="in.foxbrain.www.Facts.intro3">

    <!-- The primary full-screen view. This can be replaced with whatever view
         is needed to present your content, e.g. VideoView, SurfaceView,
         TextureView, etc. -->
    <VideoView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:keepScreenOn="true"
        android:id="@+id/videoView" />

    <!-- This FrameLayout insets its children based on system windows using
         android:fitsSystemWindows. -->
</FrameLayout>







//introductory video code.java



package in.foxbrain.www.Facts;

import in.foxbrain.www.Facts.util.SystemUiHider;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.MenuItem;
import android.support.v4.app.NavUtils;
import android.widget.Button;
import android.widget.MediaController;
import android.widget.VideoView;


/**
 * An example full-screen activity that shows and hides the system UI (i.e.
 * status bar and navigation/system bar) with user interaction.
 *
 * @see SystemUiHider
 */
public class intro3 extends Activity{
    private static final boolean TOGGLE_ON_CLICK = true;

    /**
     * The flags to pass to {@link SystemUiHider#getInstance}.
     */
    private static final int HIDER_FLAGS = SystemUiHider.FLAG_HIDE_NAVIGATION;

    /**
     * The instance of the {@link SystemUiHider} for this activity.
     */
    private SystemUiHider mSystemUiHider;
    SharedPreferences aboutact;
    public String fcheck = "WFirstTime";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        overridePendingTransition(R.anim.activity_open_translate,R.anim.activity_close_scale);
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_intro3);
        VideoView videoview = (VideoView) findViewById(R.id.videoView);

        Uri uri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.miniature);

        videoview.setVideoURI(uri);
        MediaController mediaController = new
                MediaController(this);
        mediaController.setAnchorView(videoview);
        videoview.setMediaController(mediaController);
        videoview.start();
        aboutact = getSharedPreferences(fcheck,0);
        SharedPreferences.Editor feditor = aboutact.edit();
        feditor.putBoolean("fvalue", true);
        feditor.commit();
        final View contentView = findViewById(R.id.videoView);
        videoview.setOnCompletionListener(new MediaPlayer.OnCompletionListener()
        {
            public void onCompletion(MediaPlayer videoview)
            {
                Intent intent = new Intent(getApplicationContext(),intro4.class);
                intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                startActivity(intent);
                overridePendingTransition(R.anim.abc_slide_in_top, R.anim.abc_slide_out_bottom);
                finishAffinity();

            }
        });


        // Set up an instance of SystemUiHider to control the system UI for
        // this activity.
        mSystemUiHider = SystemUiHider.getInstance(this, contentView, HIDER_FLAGS);
        mSystemUiHider.setup();
        // Set up the user interaction to manually show or hide the system UI.
        contentView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (TOGGLE_ON_CLICK) {
                    mSystemUiHider.toggle();
                } else {
                    mSystemUiHider.show();
                }
            }
        });

        // Upon interacting with UI controls, delay any scheduled hide()
        // operations to prevent the jarring behavior of controls going away
        // while interacting with the UI.

    }
}

0 comments :

Post a Comment