Example usage for android.widget VideoView setVisibility

List of usage examples for android.widget VideoView setVisibility

Introduction

In this page you can find the example usage for android.widget VideoView setVisibility.

Prototype

@Override
    public void setVisibility(int visibility) 

Source Link

Usage

From source file:com.yahoo.hakunamatata.fragments.GuideFragment.java

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    if (bgRes == R.drawable.gd4) {
        getView().findViewById(R.id.image).setVisibility(View.GONE);
        // getView().findViewById(R.id.youtubeplayerfragment_container).setVisibility(View.VISIBLE);
        VideoView videoView = (VideoView) getView().findViewById(R.id.videoview);
        getView().findViewById(R.id.image).setVisibility(View.GONE);
        videoView.setVisibility(View.VISIBLE);
        //if you want the controls to appear
        videoView.setMediaController(new MediaController(getActivity()));
        Uri video = Uri/*w  w  w.  jav a2s.co  m*/
                .parse("android.resource://" + getActivity().getPackageName() + "/" + R.raw.lionlaughhahahaha); //do not add any extension
        //if your file is named sherif.mp4 and placed in /raw
        //use R.raw.sherif
        videoView.setVideoURI(video);
        videoView.start();
        //            PlayerYouTubeFrag youTubePlayerFragment = PlayerYouTubeFrag.newInstance("https://www.youtube.com/watch?v=VPRuL9ACZeM");
        //            getChildFragmentManager().beginTransaction().add(R.id.youtubeplayerfragment_container, youTubePlayerFragment).commit();
        //            getChildFragmentManager().executePendingTransactions();
        //            youTubePlayerFragment.init();
    } else {
        imageView = (ImageView) getView().findViewById(R.id.image);
        Picasso.with(getActivity().getBaseContext()).load(bgRes).into(imageView);
    }

    //imageView.setBackgroundResource(bgRes);
}

From source file:im.neon.adapters.VectorMediasViewerAdapter.java

/**
 * Switch from the video view to the video thumbnail
 * @param view the page view//from   ww  w.  j a va2s.c  o  m
 * @param display trur to display the video thumbnail, false to display the video player
 */
private void displayVideoThumbnail(final View view, boolean display) {
    final VideoView videoView = (VideoView) view.findViewById(R.id.media_slider_videoview);
    final ImageView thumbView = (ImageView) view.findViewById(R.id.media_slider_video_thumbnail);
    final ImageView playView = (ImageView) view.findViewById(R.id.media_slider_video_playView);

    videoView.setVisibility(display ? View.GONE : View.VISIBLE);
    thumbView.setVisibility(display ? View.VISIBLE : View.GONE);
    playView.setVisibility(display ? View.VISIBLE : View.GONE);
}

From source file:com.cw.litenote.note.Note_adapter.java

private void showPictureView(int position, TouchImageView imageView, VideoView videoView,
        CustomWebView linkWebView, ProgressBar spinner) {
    String linkUri = db_page.getNoteLinkUri(position, true);
    String pictureUri = db_page.getNotePictureUri(position, true);
    String audioUri = db_page.getNoteAudioUri(position, true);
    String drawingUri = db_page.getNoteDrawingUri(position, true);

    // Check if Uri is for YouTube
    if (Util.isEmptyString(pictureUri) && Util.isYouTubeLink(linkUri)) {
        pictureUri = "http://img.youtube.com/vi/" + Util.getYoutubeId(linkUri) + "/0.jpg";//??? how to get this jpg for a playlist
        System.out.println("Note_adapter / _showPictureView / YouTube pictureUri = " + pictureUri);
    } else if (UtilImage.hasImageExtension(drawingUri, act))
        pictureUri = drawingUri;// w w w .  ja  v  a 2s .c  om

    // show image view
    if (UtilImage.hasImageExtension(pictureUri, act)
            || (Util.isEmptyString(pictureUri) && Util.isEmptyString(audioUri) && Util.isEmptyString(linkUri))) // for wrong path icon
    {
        System.out.println("Note_adapter / _showPictureView / show image view");
        videoView.setVisibility(View.GONE);
        linkWebView.setVisibility(View.GONE);
        UtilVideo.mVideoView = null;
        imageView.setVisibility(View.VISIBLE);
        showImageByTouchImageView(spinner, imageView, pictureUri, position);
    }
    // show video view
    else if (UtilVideo.hasVideoExtension(pictureUri, act)) {
        System.out.println("Note_adapter / _showPictureView / show video view");
        linkWebView.setVisibility(View.GONE);
        imageView.setVisibility(View.GONE);
        videoView.setVisibility(View.VISIBLE);
    }
    // show audio thumb nail view
    else if (Util.isEmptyString(pictureUri) && !Util.isEmptyString(audioUri)) {
        System.out.println("Note_adapter / _showPictureView / show audio thumb nail view");
        videoView.setVisibility(View.GONE);
        UtilVideo.mVideoView = null;
        linkWebView.setVisibility(View.GONE);
        imageView.setVisibility(View.VISIBLE);
        try {
            AsyncTaskAudioBitmap audioAsyncTask;
            audioAsyncTask = new AsyncTaskAudioBitmap(act, audioUri, imageView, null, false);
            audioAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "Searching media ...");
        } catch (Exception e) {
            System.out.println("Note_adapter / _AsyncTaskAudioBitmap / exception");
        }
    }
    // show link thumb view
    else if (Util.isEmptyString(pictureUri) && Util.isEmptyString(audioUri) && !Util.isEmptyString(linkUri)) {
        System.out.println("Note_adapter / _showPictureView / show link thumb view");
        videoView.setVisibility(View.GONE);
        UtilVideo.mVideoView = null;
        imageView.setVisibility(View.GONE);
        linkWebView.setVisibility(View.VISIBLE);
    } else
        System.out.println("Note_adapter / _showPictureView / show none");
}