Search in sources :

Example 6 with MediaController

use of android.widget.MediaController in project android by nextcloud.

the class PreviewVideoActivity method onAccountSet.

@Override
protected void onAccountSet(boolean stateWasRecovered) {
    super.onAccountSet(stateWasRecovered);
    if (getAccount() != null) {
        OCFile file = getFile();
        // / Validate handled file  (first image to preview)
        if (file == null) {
            throw new IllegalStateException("Instanced with a NULL OCFile");
        }
        if (!MimeTypeUtil.isVideo(file)) {
            throw new IllegalArgumentException("Non-video file passed as argument");
        }
        file = getStorageManager().getFileById(file.getFileId());
        if (file != null) {
            if (file.isDown()) {
                mVideoPlayer.setVideoURI(file.getStorageUri());
            } else {
                // not working yet
                String url;
                try {
                    url = AccountUtils.constructFullURLForAccount(this, getAccount()) + file.getRemotePath();
                    mVideoPlayer.setVideoURI(Uri.parse(url));
                } catch (AccountNotFoundException e) {
                    onError(null, MediaService.OC_MEDIA_ERROR, R.string.media_err_no_account);
                }
            }
            // create and prepare control panel for the user
            mMediaController = new MediaController(this);
            mMediaController.setMediaPlayer(mVideoPlayer);
            mMediaController.setAnchorView(mVideoPlayer);
            mVideoPlayer.setMediaController(mMediaController);
        } else {
            finish();
        }
    } else {
        finish();
    }
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) MediaController(android.widget.MediaController) AccountNotFoundException(com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException)

Example 7 with MediaController

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

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 8 with MediaController

use of android.widget.MediaController in project AisenWeiBo by wangdan.

the class VideoPlayerActivity method initPlayer.

private void initPlayer(Uri uri) {
    videoUri = uri;
    mediaController = new MediaController(this);
    mediaController.setAnchorView(mVideoPlayer);
    mVideoPlayer.setMediaController(mediaController);
    mVideoPlayer.requestFocus();
    mVideoPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {

        @Override
        public void onPrepared(MediaPlayer mp) {
            // if (mPlayingWhenPaused)
            mVideoPlayer.start();
            layoutContent.setVisibility(View.VISIBLE);
            progressBar.setVisibility(View.GONE);
            invalidateOptionsMenu();
        }
    });
    mVideoPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() {

        @Override
        public boolean onError(MediaPlayer mp, int what, int extra) {
            Logger.w(TAG, "onError what=%d, extra=%d", what, extra);
            String err = getResources().getString(R.string.toast_video_play_error, what);
            showMessage(err);
            return false;
        }
    });
    mVideoPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {

        @Override
        public void onCompletion(MediaPlayer mp) {
            Logger.w(TAG, "onCompletion");
            mVideoPlayer.seekTo(1);
        }
    });
    mVideoPlayer.setVideoURI(uri);
    invalidateOptionsMenu();
    mDownloadProxy.attach(this);
}
Also used : MediaController(android.widget.MediaController) MediaPlayer(android.media.MediaPlayer)

Example 9 with MediaController

use of android.widget.MediaController in project instructure-android by instructure.

the class MediaUploadFragment method setupViews.

private void setupViews(final View rootView) {
    mediaController = new MediaController(getActivity());
    videoView = (VideoViewWithBackground) rootView.findViewById(R.id.videoView);
}
Also used : MediaController(android.widget.MediaController)

Example 10 with MediaController

use of android.widget.MediaController in project weiui by kuaifan.

the class PictureVideoPlayActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.picture_activity_video_play);
    video_path = getIntent().getStringExtra("video_path");
    picture_left_back = (ImageView) findViewById(R.id.picture_left_back);
    mVideoView = (VideoView) findViewById(R.id.video_view);
    mVideoView.setBackgroundColor(Color.BLACK);
    iv_play = (ImageView) findViewById(R.id.iv_play);
    mMediaController = new MediaController(this);
    mVideoView.setOnCompletionListener(this);
    mVideoView.setOnPreparedListener(this);
    mVideoView.setMediaController(mMediaController);
    picture_left_back.setOnClickListener(this);
    iv_play.setOnClickListener(this);
}
Also used : MediaController(android.widget.MediaController)

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