Search in sources :

Example 26 with MediaController

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

the class VideoDumpActivity method createView.

private View createView() {
    mVideoView = new VideoDumpView(this);
    mVideoView.setMediaController(new MediaController(context));
    LinearLayout mainLayout = new LinearLayout(this);
    mainLayout.addView(mVideoView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
    return mainLayout;
}
Also used : MediaController(android.widget.MediaController) LinearLayout(android.widget.LinearLayout)

Example 27 with MediaController

use of android.widget.MediaController in project Tusky by Vavassor.

the class ViewVideoActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_video);
    ButterKnife.bind(this);
    setSupportActionBar(toolbar);
    ActionBar bar = getSupportActionBar();
    if (bar != null) {
        bar.setTitle(null);
        bar.setDisplayHomeAsUpEnabled(true);
        bar.setDisplayShowHomeEnabled(true);
    }
    String url = getIntent().getStringExtra("url");
    videoView.setVideoPath(url);
    MediaController controller = new MediaController(this);
    controller.setMediaPlayer(videoView);
    videoView.setMediaController(controller);
    videoView.requestFocus();
    videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {

        @Override
        public void onPrepared(MediaPlayer mp) {
            progressBar.setVisibility(View.GONE);
            mp.setLooping(true);
        }
    });
    videoView.start();
}
Also used : MediaController(android.widget.MediaController) ActionBar(android.support.v7.app.ActionBar) MediaPlayer(android.media.MediaPlayer)

Example 28 with MediaController

use of android.widget.MediaController in project cw-andtutorials by commonsguy.

the class HelpCast method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    getWindow().setFormat(PixelFormat.TRANSLUCENT);
    setContentView(R.layout.helpcast);
    File clip = new File(Environment.getExternalStorageDirectory(), "helpcast.mp4");
    if (clip.exists()) {
        video = (VideoView) findViewById(R.id.video);
        video.setVideoPath(clip.getAbsolutePath());
        ctlr = new MediaController(this);
        ctlr.setMediaPlayer(video);
        video.setMediaController(ctlr);
        video.requestFocus();
        video.start();
    }
}
Also used : MediaController(android.widget.MediaController) File(java.io.File)

Example 29 with MediaController

use of android.widget.MediaController in project Signal-Android by signalapp.

the class VideoPlayer method initializeVideoViewControls.

private void initializeVideoViewControls(@NonNull VideoView videoView) {
    MediaController mediaController = new MediaController(getContext());
    mediaController.setAnchorView(videoView);
    mediaController.setMediaPlayer(videoView);
    videoView.setMediaController(mediaController);
}
Also used : MediaController(android.widget.MediaController)

Example 30 with MediaController

use of android.widget.MediaController 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 = findViewById(R.id.video_view);
    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 = 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)

Aggregations

MediaController (android.widget.MediaController)35 MediaPlayer (android.media.MediaPlayer)10 View (android.view.View)7 LinearLayout (android.widget.LinearLayout)6 VideoView (android.widget.VideoView)5 OnPreparedListener (android.media.MediaPlayer.OnPreparedListener)3 OnClickListener (android.view.View.OnClickListener)3 File (java.io.File)3 Intent (android.content.Intent)2 ActionBar (android.support.v7.app.ActionBar)2 KeyEvent (android.view.KeyEvent)2 Button (android.widget.Button)2 OCFile (com.owncloud.android.datamodel.OCFile)2 AccountNotFoundException (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException)2 SharedPreferences (android.content.SharedPreferences)1 Uri (android.net.Uri)1 Nullable (android.support.annotation.Nullable)1 MotionEvent (android.view.MotionEvent)1 InputMethodManager (android.view.inputmethod.InputMethodManager)1 ProgressBar (android.widget.ProgressBar)1