Search in sources :

Example 1 with VideoView

use of android.widget.VideoView in project qksms by moezbhatti.

the class SlideView method setVideo.

public void setVideo(String name, Uri video) {
    if (mVideoView == null) {
        mVideoView = new VideoView(mContext);
        addView(mVideoView, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 0, 0));
        if (DEBUG) {
            mVideoView.setBackgroundColor(0xFFFF0000);
        }
    }
    if (LOCAL_LOGV) {
        Log.v(TAG, "Changing video source to " + video);
    }
    mVideoView.setVisibility(View.VISIBLE);
    mVideoView.setVideoURI(video);
}
Also used : VideoView(android.widget.VideoView)

Example 2 with VideoView

use of android.widget.VideoView in project NewPipe by TeamNewPipe.

the class PlayVideoActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_play_video);
    setVolumeControlStream(AudioManager.STREAM_MUSIC);
    //set background arrow style
    getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_arrow_back_white_24dp);
    isLandscape = checkIfLandscape();
    hasSoftKeys = checkIfHasSoftKeys();
    actionBar = getSupportActionBar();
    assert actionBar != null;
    actionBar.setDisplayHomeAsUpEnabled(true);
    Intent intent = getIntent();
    if (mediaController == null) {
        //prevents back button hiding media controller controls (after showing them)
        //instead of exiting video
        //see http://stackoverflow.com/questions/6051825
        //also solves https://github.com/theScrabi/NewPipe/issues/99
        mediaController = new MediaController(this) {

            @Override
            public boolean dispatchKeyEvent(KeyEvent event) {
                int keyCode = event.getKeyCode();
                final boolean uniqueDown = event.getRepeatCount() == 0 && event.getAction() == KeyEvent.ACTION_DOWN;
                if (keyCode == KeyEvent.KEYCODE_BACK) {
                    if (uniqueDown) {
                        if (isShowing()) {
                            finish();
                        } else {
                            hide();
                        }
                    }
                    return true;
                }
                return super.dispatchKeyEvent(event);
            }
        };
    }
    //convert from seconds to milliseconds
    position = intent.getIntExtra(START_POSITION, 0) * 1000;
    videoView = (VideoView) findViewById(R.id.video_view);
    progressBar = (ProgressBar) findViewById(R.id.play_video_progress_bar);
    try {
        videoView.setMediaController(mediaController);
        videoView.setVideoURI(Uri.parse(intent.getStringExtra(STREAM_URL)));
    } catch (Exception e) {
        e.printStackTrace();
    }
    videoView.requestFocus();
    videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {

        @Override
        public void onPrepared(MediaPlayer mp) {
            progressBar.setVisibility(View.GONE);
            videoView.seekTo(position);
            if (position <= 0) {
                videoView.start();
                showUi();
            } else {
                videoView.pause();
            }
        }
    });
    videoUrl = intent.getStringExtra(VIDEO_URL);
    Button button = (Button) findViewById(R.id.content_button);
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (uiIsHidden) {
                showUi();
            } else {
                hideUi();
            }
        }
    });
    decorView = getWindow().getDecorView();
    decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {

        @Override
        public void onSystemUiVisibilityChange(int visibility) {
            if (visibility == View.VISIBLE && uiIsHidden) {
                showUi();
            }
        }
    });
    if (android.os.Build.VERSION.SDK_INT >= 17) {
        decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
    }
    prefs = getPreferences(Context.MODE_PRIVATE);
    if (prefs.getBoolean(PREF_IS_LANDSCAPE, false) && !isLandscape) {
        toggleOrientation();
    }
}
Also used : KeyEvent(android.view.KeyEvent) MediaController(android.widget.MediaController) Button(android.widget.Button) Intent(android.content.Intent) View(android.view.View) VideoView(android.widget.VideoView) MediaPlayer(android.media.MediaPlayer)

Example 3 with VideoView

use of android.widget.VideoView in project android_frameworks_base by DirtyUnicorns.

the class VideoViewCaptureActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mVideoView = new VideoView(this);
    mVideoView.setOnPreparedListener(mp -> {
        mp.setLooping(true);
        mVideoWidth = mp.getVideoWidth();
        mVideoHeight = mp.getVideoHeight();
        mVideoView.start();
    });
    Uri uri = Uri.parse("android.resource://com.android.test.hwui/" + R.raw.colorgrid_video);
    mVideoView.setVideoURI(uri);
    Button button = new Button(this);
    button.setText("Copy bitmap to /sdcard/surfaceview.png");
    button.setOnClickListener((View v) -> {
        final Bitmap b = Bitmap.createBitmap(mVideoWidth, mVideoHeight, Bitmap.Config.ARGB_8888);
        PixelCopy.request(mVideoView, b, (int result) -> {
            if (result != PixelCopy.SUCCESS) {
                Toast.makeText(VideoViewCaptureActivity.this, "Failed to copy", Toast.LENGTH_SHORT).show();
                return;
            }
            try {
                try (FileOutputStream out = new FileOutputStream(Environment.getExternalStorageDirectory() + "/surfaceview.png")) {
                    b.compress(Bitmap.CompressFormat.PNG, 100, out);
                }
            } catch (Exception e) {
            // Ignore
            }
        }, mVideoView.getHandler());
    });
    FrameLayout content = new FrameLayout(this);
    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.addView(button, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    layout.addView(mVideoView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
    content.addView(layout, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
    setContentView(content);
}
Also used : Bitmap(android.graphics.Bitmap) Button(android.widget.Button) VideoView(android.widget.VideoView) FileOutputStream(java.io.FileOutputStream) FrameLayout(android.widget.FrameLayout) Uri(android.net.Uri) View(android.view.View) VideoView(android.widget.VideoView) LinearLayout(android.widget.LinearLayout)

Example 4 with VideoView

use of android.widget.VideoView in project Small by wequick.

the class VideoActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_video);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    VideoView videoView = (VideoView) findViewById(R.id.video_view);
    final String uri = "android.resource://" + getPackageName() + "/" + R.raw.fix_429;
    videoView.setVideoURI(Uri.parse(uri));
    // Loop
    videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {

        @Override
        public void onPrepared(MediaPlayer mp) {
            mp.setLooping(true);
        }
    });
    // Play
    videoView.start();
}
Also used : VideoView(android.widget.VideoView) MediaPlayer(android.media.MediaPlayer)

Example 5 with VideoView

use of android.widget.VideoView in project Tapad by berict.

the class TutorialHelper method playMotionAnimation.

void playMotionAnimation(int btnId, int phId, int motionId, Activity activity) {
    VideoView videoView;
    View placeholder;
    videoView = (VideoView) activity.findViewById(btnId);
    placeholder = (View) activity.findViewById(phId);
    animator(videoView, placeholder, motionId, activity);
    Log.i("MotionAnimation", "Animation played on " + activity.getResources().getResourceEntryName(phId));
}
Also used : VideoView(android.widget.VideoView) View(android.view.View) VideoView(android.widget.VideoView)

Aggregations

VideoView (android.widget.VideoView)41 View (android.view.View)25 MediaPlayer (android.media.MediaPlayer)13 TextView (android.widget.TextView)12 FrameLayout (android.widget.FrameLayout)10 ImageView (android.widget.ImageView)9 Uri (android.net.Uri)8 Button (android.widget.Button)7 Bitmap (android.graphics.Bitmap)6 LinearLayout (android.widget.LinearLayout)6 Intent (android.content.Intent)5 MediaController (android.widget.MediaController)5 WebView (android.webkit.WebView)4 FileOutputStream (java.io.FileOutputStream)4 MotionEvent (android.view.MotionEvent)3 OnClickListener (android.view.View.OnClickListener)3 AdapterView (android.widget.AdapterView)3 KeyEvent (android.view.KeyEvent)2 AutoCompleteTextView (android.widget.AutoCompleteTextView)2 HorizontalScrollView (android.widget.HorizontalScrollView)2