android.widget.VideoView Java Examples

The following examples show how to use android.widget.VideoView. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VideoActivity.java    From Small with Apache License 2.0 7 votes vote down vote up
@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();
}
 
Example #2
Source File: VideoViewDemo.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.videoview);
    mVideoView = (VideoView) findViewById(R.id.surface_view);

    if (path == "") {
        // Tell the user to provide a media file URL/path.
        Toast.makeText(
                VideoViewDemo.this,
                "Please edit VideoViewDemo Activity, and set path"
                        + " variable to your media file URL/path",
                Toast.LENGTH_LONG).show();

    } else {

        /*
         * Alternatively,for streaming media you can use
         * mVideoView.setVideoURI(Uri.parse(URLstring));
         */
        mVideoView.setVideoPath(path);
        mVideoView.setMediaController(new MediaController(this));
        mVideoView.requestFocus();

    }
}
 
Example #3
Source File: PreviewMediaFragment.java    From Cirrus_depricated with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    Log_OC.v(TAG, "onCreateView");

    mView = inflater.inflate(R.layout.file_preview, container, false);

    mImagePreview = (ImageView) mView.findViewById(R.id.image_preview);
    mVideoPreview = (VideoView) mView.findViewById(R.id.video_preview);
    mVideoPreview.setOnTouchListener(this);

    mMediaController = (MediaControlView) mView.findViewById(R.id.media_controller);

    return mView;
}
 
Example #4
Source File: VideoDivideActivity.java    From PLDroidShortVideo with Apache License 2.0 6 votes vote down vote up
private void initView() {
    setContentView(R.layout.activity_video_divide);

    mPreview = (VideoView) findViewById(R.id.preview);
    mPlaybackButton = (ImageButton) findViewById(R.id.pause_playback);
    mFrameListParent = (ViewGroup) findViewById(R.id.recycler_parent);
    mFrameList = (RecyclerView) findViewById(R.id.recycler_frame_list);
    mScrollViewParent = (FrameLayout) findViewById(R.id.scroll_view_parent);
    mScrollView = (ObservableHorizontalScrollView) findViewById(R.id.scroll_view);

    ImageView middleLineImage = (ImageView) findViewById(R.id.middle_line_image);
    ViewGroup topGroup = (ViewGroup) findViewById(R.id.top_group);

    WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    mFrameWidth = mFrameHeight = wm.getDefaultDisplay().getWidth() / 6;
    middleLineImage.getLayoutParams().height = mFrameHeight;

    mScrollView.setOnScrollListener(new OnViewScrollListener());
    topGroup.setOnTouchListener(new OnTopViewTouchListener());
}
 
Example #5
Source File: VideoTrimActivity.java    From PLDroidShortVideo with Apache License 2.0 6 votes vote down vote up
private void init(String videoPath) {
    setContentView(R.layout.activity_trim);
    TextView duration = (TextView) findViewById(R.id.duration);
    mPreview = (VideoView) findViewById(R.id.preview);

    mShortVideoTrimmer = new PLShortVideoTrimmer(this, videoPath, Config.TRIM_FILE_PATH);
    mMediaFile = new PLMediaFile(videoPath);

    mSelectedEndMs = mDurationMs = mMediaFile.getDurationMs();
    duration.setText("时长: " + formatTime(mDurationMs));
    Log.i(TAG, "video duration: " + mDurationMs);

    mVideoFrameCount = mMediaFile.getVideoFrameCount(false);
    Log.i(TAG, "video frame count: " + mVideoFrameCount);

    mPreview.setVideoPath(videoPath);
    mPreview.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
        @Override
        public void onCompletion(MediaPlayer mediaPlayer) {
            play();
        }
    });

    initVideoFrameList();
}
 
Example #6
Source File: LocalPlayerActivity.java    From cast-videos-android with Apache License 2.0 6 votes vote down vote up
private void loadViews() {
    mVideoView = (VideoView) findViewById(R.id.videoView1);
    mTitleView = (TextView) findViewById(R.id.textView1);
    mDescriptionView = (TextView) findViewById(R.id.textView2);
    mDescriptionView.setMovementMethod(new ScrollingMovementMethod());
    mAuthorView = (TextView) findViewById(R.id.textView3);
    mStartText = (TextView) findViewById(R.id.startText);
    mStartText.setText(Utils.formatMillis(0));
    mEndText = (TextView) findViewById(R.id.endText);
    mSeekbar = (SeekBar) findViewById(R.id.seekBar1);
    mPlayPause = (ImageView) findViewById(R.id.imageView2);
    mLoading = (ProgressBar) findViewById(R.id.progressBar1);
    mControllers = findViewById(R.id.controllers);
    mContainer = findViewById(R.id.container);
    mCoverArt = (ImageView) findViewById(R.id.coverArtView);
    ViewCompat.setTransitionName(mCoverArt, getString(R.string.transition_image));
    mPlayCircle = (ImageButton) findViewById(R.id.play_circle);
    mPlayCircle.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            togglePlayback();
        }
    });
}
 
Example #7
Source File: FormEntryActivity.java    From commcare-android with Apache License 2.0 6 votes vote down vote up
private void restoreInlineVideoState() {
    if (indexOfWidgetWithVideoPlaying != -1) {
        QuestionWidget widgetWithVideoToResume = uiController.questionsView.getWidgets().get(indexOfWidgetWithVideoPlaying);
        VideoView inlineVideo = widgetWithVideoToResume.findViewById(MediaLayout.INLINE_VIDEO_PANE_ID);
        if (inlineVideo != null) {
            inlineVideo.seekTo(positionOfVideoProgress);
            inlineVideo.start();
        } else {
            Logger.log(LogTypes.SOFT_ASSERT,
                    "No inline video was found at the question widget index for which a " +
                            "video had been playing before the activity was paused");
        }

        // Reset values now that we have restored
        indexOfWidgetWithVideoPlaying = -1;
        positionOfVideoProgress = -1;
    }
}
 
Example #8
Source File: LocalPlayerActivity.java    From CastVideos-android with Apache License 2.0 6 votes vote down vote up
private void loadViews() {
    mVideoView = (VideoView) findViewById(R.id.videoView1);
    mTitleView = (TextView) findViewById(R.id.titleTextView);
    mDescriptionView = (TextView) findViewById(R.id.descriptionTextView);
    mDescriptionView.setMovementMethod(new ScrollingMovementMethod());
    mAuthorView = (TextView) findViewById(R.id.authorTextView);
    mStartText = (TextView) findViewById(R.id.startText);
    mStartText.setText(Utils.formatMillis(0));
    mEndText = (TextView) findViewById(R.id.endText);
    mSeekbar = (SeekBar) findViewById(R.id.seekBar1);
    mPlayPause = (ImageView) findViewById(R.id.playPauseImageView);
    mLoading = (ProgressBar) findViewById(R.id.progressBar1);
    mControllers = findViewById(R.id.controllers);
    mContainer = findViewById(R.id.container);
    mCoverArt = (NetworkImageView) findViewById(R.id.coverArtView);
    ViewCompat.setTransitionName(mCoverArt, getString(R.string.transition_image));
    mPlayCircle = (ImageButton) findViewById(R.id.play_circle);
    mPlayCircle.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            togglePlayback();
        }
    });
}
 
Example #9
Source File: MediaFragment.java    From MediaLoader with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_media, container, false);
    mVideoView = (VideoView) rootView.findViewById(R.id.videoView);
    mVideoViewSeekBar = (VideoViewSeekBar) rootView.findViewById(R.id.mediaSeekBar);
    mVideoViewSeekBar.setVideoView(mVideoView);
    mUrl = getArguments().getString(BUNDLE_KEY_URL);

    mMediaLoader = MediaLoader.getInstance(getContext());
    mMediaLoader.addDownloadListener(mUrl, this);
    boolean isCached = mMediaLoader.isCached(mUrl);
    if (isCached) {
        mVideoViewSeekBar.setSecondaryProgress(mVideoViewSeekBar.getMax());
    }
    mVideoView.setVideoPath(mMediaLoader.getProxyUrl(mUrl));
    mVideoViewSeekBar.start();
    return rootView;
}
 
Example #10
Source File: VideoLazyLoadFragment.java    From MediaLoader with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_media, container, false);
    mVideoView = (VideoView) rootView.findViewById(R.id.videoView);
    mVideoViewSeekBar = (VideoViewSeekBar) rootView.findViewById(R.id.mediaSeekBar);
    mVideoViewSeekBar.setVideoView(mVideoView);
    mUrl = getArguments().getString(BUNDLE_KEY_URL);

    mMediaLoader = MediaLoader.getInstance(getContext());
    mMediaLoader.addDownloadListener(mUrl, this);
    boolean isCached = mMediaLoader.isCached(mUrl);
    if (isCached) {
        mVideoViewSeekBar.setSecondaryProgress(mVideoViewSeekBar.getMax());
    }
    return rootView;
}
 
Example #11
Source File: VideoPlayerActivity.java    From ScrollGalleryView with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    String url = getIntent().getExtras().getString(Constants.URL);
    setContentView(R.layout.video_fragment);
    final VideoView videoView = (VideoView) findViewById(R.id.videoView);
    videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mp) {
            View progress = findViewById(R.id.videoProgress);
            progress.setVisibility(View.GONE);

            videoView.requestFocus();
            MediaController vidControl = new MediaController(VideoPlayerActivity.this);
            vidControl.setAnchorView(videoView);
            videoView.setMediaController(vidControl);
            videoView.start();
        }
    });
    videoView.setVideoURI(Uri.parse(url));
}
 
Example #12
Source File: VideoPagerFragment.java    From MediaLoader with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_media, container, false);
    mVideoView = (VideoView) rootView.findViewById(R.id.videoView);
    mVideoViewSeekBar = (VideoViewSeekBar) rootView.findViewById(R.id.mediaSeekBar);
    mVideoViewSeekBar.setVideoView(mVideoView);
    mUrl = getArguments().getString(BUNDLE_KEY_URL);

    mMediaLoader = MediaLoader.getInstance(getContext());
    mMediaLoader.addDownloadListener(mUrl, this);
    boolean isCached = mMediaLoader.isCached(mUrl);
    if (isCached) {
        mVideoViewSeekBar.setSecondaryProgress(mVideoViewSeekBar.getMax());
    }
    mVideoView.setVideoPath(mMediaLoader.getProxyUrl(mUrl));
    return rootView;
}
 
Example #13
Source File: AudioVideoVideoPlayActivity.java    From coursera-android with MIT License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.main);

	// Get a reference to the VideoView
	
	mVideoView = (VideoView) findViewById(R.id.videoViewer);

	// Add a Media controller to allow forward/reverse/pause/resume 
	
	final MediaController mMediaController = new MediaController(
			AudioVideoVideoPlayActivity.this, true);
	
	mMediaController.setEnabled(false);

	mVideoView.setMediaController(mMediaController);
	
	mVideoView
			.setVideoURI(Uri
					.parse("android.resource://course.examples.AudioVideo.VideoPlay/raw/moon"));
	
	// Add an OnPreparedListener to enable the MediaController once the video is ready
	mVideoView.setOnPreparedListener(new OnPreparedListener() {

		@Override
		public void onPrepared(MediaPlayer mp) {
			mMediaController.setEnabled(true);
		}
	});
}
 
Example #14
Source File: BrowserActivity.java    From browser with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onShowCustomView(View view, int requestedOrientation, CustomViewCallback callback) {
	if (view == null) {
		return;
	}
	if (mCustomView != null && callback != null) {
		callback.onCustomViewHidden();
		return;
	}
	try {
		view.setKeepScreenOn(true);
	} catch (SecurityException e) {
		Log.e(Constants.TAG, "WebView is not allowed to keep the screen on");
	}
	mOriginalOrientation = getRequestedOrientation();
	FrameLayout decor = (FrameLayout) getWindow().getDecorView();
	mFullscreenContainer = new FullscreenHolder(this);
	mCustomView = view;
	mFullscreenContainer.addView(mCustomView, COVER_SCREEN_PARAMS);
	decor.addView(mFullscreenContainer, COVER_SCREEN_PARAMS);
	setFullscreen(true);
	getCurrentWebView().setVisibility(View.GONE);
	if (view instanceof FrameLayout) {
		if (((FrameLayout) view).getFocusedChild() instanceof VideoView) {
			mVideoView = (VideoView) ((FrameLayout) view).getFocusedChild();
			mVideoView.setOnErrorListener(new VideoCompletionListener());
			mVideoView.setOnCompletionListener(new VideoCompletionListener());
		}
	}
	mCustomViewCallback = callback;
}
 
Example #15
Source File: MediaUtil.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Loads the video specified by mediaPath into the given VideoView.
 *
 * Note that if the mediaPath is an asset or an URL, the video must be copied
 * to a temp file and then loaded from there. This could have performance
 * implications.
 *
 * @param videoView the VideoView
 * @param form the Form
 * @param mediaPath the path to the media
 */
public static void loadVideoView(VideoView videoView, Form form, String mediaPath)
    throws IOException {
  MediaSource mediaSource = determineMediaSource(form, mediaPath);
  switch (mediaSource) {
    case ASSET:
    case URL:
      File tempFile = cacheMediaTempFile(form, mediaPath, mediaSource);
      videoView.setVideoPath(tempFile.getAbsolutePath());
      return;

    case REPL_ASSET:
      form.assertPermission(Manifest.permission.READ_EXTERNAL_STORAGE);
      videoView.setVideoPath(replAssetPath(mediaPath));
      return;

    case SDCARD:
      form.assertPermission(Manifest.permission.READ_EXTERNAL_STORAGE);
      videoView.setVideoPath(mediaPath);
      return;

    case FILE_URL:
      if (isExternalFileUrl(mediaPath)) {
        form.assertPermission(Manifest.permission.READ_EXTERNAL_STORAGE);
      }
      videoView.setVideoPath(fileUrlToFilePath(mediaPath));
      return;

    case CONTENT_URI:
      videoView.setVideoURI(Uri.parse(mediaPath));
      return;

    case CONTACT_URI:
      throw new IOException("Unable to load video for contact " + mediaPath + ".");
  }
  throw new IOException("Unable to load video " + mediaPath + ".");
}
 
Example #16
Source File: PreviewVideoActivity.java    From Cirrus_depricated with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Called when the activity is first created.
 *
 *  Searches for an {@link OCFile} and ownCloud {@link Account} holding it in the starting {@link Intent}.
 *
 *  The {@link Account} is unnecessary if the file is downloaded; else, the {@link Account} is used to
 *  try to stream the remote file - TODO get the streaming works
 *
 *  {@inheritDoc}
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log_OC.v(TAG, "onCreate");

    setContentView(R.layout.video_layout);

    if (savedInstanceState == null) {
        Bundle extras = getIntent().getExtras();
        mSavedPlaybackPosition = extras.getInt(EXTRA_START_POSITION);
        mAutoplay = extras.getBoolean(EXTRA_AUTOPLAY);

    } else {
        mSavedPlaybackPosition = savedInstanceState.getInt(EXTRA_START_POSITION);
        mAutoplay = savedInstanceState.getBoolean(EXTRA_AUTOPLAY);
    }

    mVideoPlayer = (VideoView) findViewById(R.id.videoPlayer);

    // set listeners to get more contol on the playback
    mVideoPlayer.setOnPreparedListener(this);
    mVideoPlayer.setOnCompletionListener(this);
    mVideoPlayer.setOnErrorListener(this);

    // keep the screen on while the playback is performed (prevents screen off by battery save)
    mVideoPlayer.setKeepScreenOn(true);
}
 
Example #17
Source File: SimpleVideoStream.java    From cordova-plugin-streaming-media with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	this.requestWindowFeature(Window.FEATURE_NO_TITLE);
	this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

	Bundle b = getIntent().getExtras();
	mVideoUrl = b.getString("mediaUrl");
	mShouldAutoClose = b.getBoolean("shouldAutoClose", true);
	mControls = b.getBoolean("controls", true);

	RelativeLayout relLayout = new RelativeLayout(this);
	relLayout.setBackgroundColor(Color.BLACK);
	RelativeLayout.LayoutParams relLayoutParam = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
	relLayoutParam.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
	mVideoView = new VideoView(this);
	mVideoView.setLayoutParams(relLayoutParam);
	relLayout.addView(mVideoView);

	// Create progress throbber
	mProgressBar = new ProgressBar(this);
	mProgressBar.setIndeterminate(true);
	// Center the progress bar
	RelativeLayout.LayoutParams pblp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
	pblp.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
	mProgressBar.setLayoutParams(pblp);
	// Add progress throbber to view
	relLayout.addView(mProgressBar);
	mProgressBar.bringToFront();

	setOrientation(b.getString("orientation"));

	setContentView(relLayout, relLayoutParam);

	play();
}
 
Example #18
Source File: Utils.java    From tv-samples with Apache License 2.0 5 votes vote down vote up
/**
 * Example for handling resizing content for overscan.  Typically you won't need to resize when
 * using the Leanback support library.
 */
public void overScan(Activity activity, VideoView videoView) {
    DisplayMetrics metrics = new DisplayMetrics();
    activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int w = (int) (metrics.widthPixels * MediaDimensions.MEDIA_WIDTH);
    int h = (int) (metrics.heightPixels * MediaDimensions.MEDIA_HEIGHT);
    int marginLeft = (int) (metrics.widthPixels * MediaDimensions.MEDIA_LEFT_MARGIN);
    int marginTop = (int) (metrics.heightPixels * MediaDimensions.MEDIA_TOP_MARGIN);
    int marginRight = (int) (metrics.widthPixels * MediaDimensions.MEDIA_RIGHT_MARGIN);
    int marginBottom = (int) (metrics.heightPixels * MediaDimensions.MEDIA_BOTTOM_MARGIN);
    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(w, h);
    lp.setMargins(marginLeft, marginTop, marginRight, marginBottom);
    videoView.setLayoutParams(lp);
}
 
Example #19
Source File: Utils.java    From androidtv-Leanback with Apache License 2.0 5 votes vote down vote up
/**
 * Example for handling resizing content for overscan.  Typically you won't need to resize when
 * using the Leanback support library.
 */
public void overScan(Activity activity, VideoView videoView) {
    DisplayMetrics metrics = new DisplayMetrics();
    activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int w = (int) (metrics.widthPixels * MediaDimensions.MEDIA_WIDTH);
    int h = (int) (metrics.heightPixels * MediaDimensions.MEDIA_HEIGHT);
    int marginLeft = (int) (metrics.widthPixels * MediaDimensions.MEDIA_LEFT_MARGIN);
    int marginTop = (int) (metrics.heightPixels * MediaDimensions.MEDIA_TOP_MARGIN);
    int marginRight = (int) (metrics.widthPixels * MediaDimensions.MEDIA_RIGHT_MARGIN);
    int marginBottom = (int) (metrics.heightPixels * MediaDimensions.MEDIA_BOTTOM_MARGIN);
    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(w, h);
    lp.setMargins(marginLeft, marginTop, marginRight, marginBottom);
    videoView.setLayoutParams(lp);
}
 
Example #20
Source File: VideoActivity.java    From ml-authentication with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.i(getClass().getName(), "onCreate");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_video);

    getWindow().setStatusBarColor(Color.parseColor("#852196"));

    LiteracyApplication literacyApplication = (LiteracyApplication) getApplicationContext();
    videoDao = literacyApplication.getDaoSession().getVideoDao();

    videoView = (VideoView) findViewById(R.id.videoView);
}
 
Example #21
Source File: VideoPlayer.java    From deltachat-android with GNU General Public License v3.0 5 votes vote down vote up
private void initializeVideoViewControls(@NonNull VideoView videoView) {
  MediaController mediaController = new MediaController(getContext());
  mediaController.setAnchorView(videoView);
  mediaController.setMediaPlayer(videoView);

  videoView.setMediaController(mediaController);
}
 
Example #22
Source File: RecorderVideoActivity.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
private void initViews() {
	btn_switch = (Button) findViewById(R.id.switch_btn);
	btn_switch.setOnClickListener(this);
	btn_switch.setVisibility(View.VISIBLE);
	mVideoView = (VideoView) findViewById(R.id.mVideoView);
	btnStart = (ImageView) findViewById(R.id.recorder_start);
	btnStop = (ImageView) findViewById(R.id.recorder_stop);
	btnStart.setOnClickListener(this);
	btnStop.setOnClickListener(this);
	mSurfaceHolder = mVideoView.getHolder();
	mSurfaceHolder.addCallback(this);
	mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
	chronometer = (Chronometer) findViewById(R.id.chronometer);
}
 
Example #23
Source File: PlayerActivity.java    From BuildingForAndroidTV with MIT License 5 votes vote down vote up
private void loadViews() {
    mVideoView = (VideoView) findViewById(R.id.videoView);
    mStartText = (TextView) findViewById(R.id.startText);
    mEndText = (TextView) findViewById(R.id.endText);
    mSeekbar = (SeekBar) findViewById(R.id.seekBar);
    mPlayPause = (ImageView) findViewById(R.id.playpause);
    mLoading = (ProgressBar) findViewById(R.id.progressBar);
    mControllers = findViewById(R.id.controllers);
    mContainer = findViewById(R.id.container);

    mVideoView.setOnClickListener(mPlayPauseHandler);
}
 
Example #24
Source File: MediaControllerEx.java    From SkyTube with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Initialises this object.  It also attaches the supplied VideoView with this MediaController.
 *
 * @param activity	Activity where this controller will run on.
 * @param videoView	VideoView that this controller will control.
 */
public MediaControllerEx(Activity activity, VideoView videoView, YouTubePlayerFragmentInterface fragmentInterface) {
	super(activity);
	this.videoView = videoView;
	this.videoView.setMediaController(this);
	this.fragmentInterface = fragmentInterface;
}
 
Example #25
Source File: VideoTest.java    From aws-device-farm-sample-app-for-android with Apache License 2.0 5 votes vote down vote up
/**
 * Registers a idling resource so it can wait for the video to be loaded/playing
 *
 * @throws Exception
 */
@Override
protected void setUp() throws Exception {
    super.setUp();
    videoPlayerIdlingResource = new VideoPlayerIdlingResource((VideoView)
            getActivity().findViewById(R.id.native_video_player));
    Espresso.registerIdlingResources(videoPlayerIdlingResource);
}
 
Example #26
Source File: MainActivity.java    From UberSplash with Apache License 2.0 5 votes vote down vote up
private void findView() {
    mVideoView = (VideoView) findViewById(R.id.videoView);
    buttonLeft = (Button) findViewById(R.id.buttonLeft);
    buttonRight = (Button) findViewById(R.id.buttonRight);
    contianer = (ViewGroup) findViewById(R.id.container);
    formView = (FormView) findViewById(R.id.formView);
    appName = (TextView) findViewById(R.id.appName);
    formView.post(new Runnable() {
        @Override
        public void run() {
            int delta = formView.getTop()+formView.getHeight();
            formView.setTranslationY(-1 * delta);
        }
    });
}
 
Example #27
Source File: LiveStuff.java    From goprohero with MIT License 5 votes vote down vote up
public void restartStream(View view){
    myVideoView = (VideoView)this.findViewById(R.id.videoView);
    MediaController mc = new MediaController(this);
    myVideoView.setMediaController(mc);
    urlStream = "http://10.5.5.9:8080/live/amba.m3u8";
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            myVideoView.setVideoURI(Uri.parse(urlStream));
            myVideoView.setMediaController(null);
            myVideoView.start();
        }

    });
}
 
Example #28
Source File: VideoPlayer.java    From Silence with GNU General Public License v3.0 5 votes vote down vote up
private void initializeVideoViewControls(@NonNull VideoView videoView) {
  MediaController mediaController = new MediaController(getContext());
  mediaController.setAnchorView(videoView);
  mediaController.setMediaPlayer(videoView);

  videoView.setMediaController(mediaController);
}
 
Example #29
Source File: VideoActivity.java    From ml-authentication with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.i(getClass().getName(), "onCreate");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_video);

    getWindow().setStatusBarColor(Color.parseColor("#852196"));

    LiteracyApplication literacyApplication = (LiteracyApplication) getApplicationContext();
    videoDao = literacyApplication.getDaoSession().getVideoDao();

    videoView = (VideoView) findViewById(R.id.videoView);
}
 
Example #30
Source File: MainActivity.java    From Android-Basics-Codes with Artistic License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);
	
	VideoView vv = (VideoView) findViewById(R.id.vv);
	vv.setVideoPath("sdcard/2.3gp");
	vv.start();
}