Video View Android Studio

In this tutorial I have explained how to create Video View Android Studio Example using Java Programming Language. Some students are request to implement using Kotlin, so in the upcoming tutorial will post about particular concepts. Actually video is very major part in everywhere because through we can easily understand the topic when read text. It’s completely save our time & prevent to affect our eyes. That’s why now YouTube is hold the 2nd place in world who spend more time. Once upon a time everyone read the text and find exact solution via books.

But now entirely it was changed & everyone migrate into video platform such as Vimeo, YouTube etc. However still no one beat YouTube platform because it’s built by Google. And no one have capacity to break Google Company products or services. In the every place, Google hold the first place because they are providing best user experience & results for end users.

video view android studio

For example if you need video application similar of YouTube ? and then we need web server for uploading videos. Then only able to fetch & display our contents in mobile application. For that you need own server from Hostinger, Hostgator or Gadaddy. Alternatively you can choose Google Cloud Firebase database for storing data up to 5GB.

If you are plan to just test the application then go for Firebase otherwise, Buy Hosting from any one of companies. Because 5GB free storage not enough for handle large amount of our data. Suppose if you are allocate space for users, then surely we need more storage. The reason is we did not judge the user video file size, therefore we need high storage server.

XML Design

In the above screenshot for the sample purpose I did not add video description. So later that change those customization based on your requirements. Moreover also edit Start Button or totally remove entire buttons navigation. You can create own design patters, but this is recommend video view size based on every mobile aspect ratio. Automatically it’s adopt the space on every mobile phones.

            <FrameLayout
                android:id="@+id/video_layout"
                android:layout_width="fill_parent"
                android:layout_height="200dp"
                android:background="@android:color/black">

                <com.universalvideoview.UniversalVideoView
                    android:id="@+id/videoView"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_gravity="center"
                    app:uvv_autoRotation="true"
                    app:uvv_fitXY="false" />

                <com.universalvideoview.UniversalMediaController
                    android:id="@+id/media_controller"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    app:uvv_scalable="true" />

            </FrameLayout>

Create Project – Video View Android Studio

Let’s see the steps for how create video file integration into java program. This is very simple but when we develop similar of YouTube application then we need more functionality, library, server etc. For that here just we add video files only. If you want to add more files then just enable the looping cocept. Already it was developed and now hide by comment section.

            View mBottomLayout;
            View mVideoLayout;
            UniversalVideoView mVideoView;
            UniversalMediaController mMediaController;

            mVideoView = (UniversalVideoView) findViewById(R.id.videoView);
            mMediaController = (UniversalMediaController) findViewById(R.id.media_controller);
            mVideoView.setMediaController(mMediaController);

            mVideoView.setVideoViewCallback(new UniversalVideoView.VideoViewCallback() {
                @Override
                public void onScaleChange(boolean isFullscreen) {
                    this.isFullscreen = isFullscreen;
                    if (isFullscreen) {
                        ViewGroup.LayoutParams layoutParams = mVideoLayout.getLayoutParams();
                        layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
                        layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT;
                        mVideoLayout.setLayoutParams(layoutParams);
                        //GONE the unconcerned views to leave room for video and controller
                        mBottomLayout.setVisibility(View.GONE);
                    } else {
                        ViewGroup.LayoutParams layoutParams = mVideoLayout.getLayoutParams();
                        layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
                        layoutParams.height = this.cachedHeight;
                        mVideoLayout.setLayoutParams(layoutParams);
                        mBottomLayout.setVisibility(View.VISIBLE);
                    }
                }

                @Override
                public void onPause(MediaPlayer mediaPlayer) { // Video pause
                    Log.d(TAG, "onPause UniversalVideoView callback");
                }

                @Override
                public void onStart(MediaPlayer mediaPlayer) { // Video start/resume to play
                    Log.d(TAG, "onStart UniversalVideoView callback");
                }

                @Override
                public void onBufferingStart(MediaPlayer mediaPlayer) {// steam start loading
                    Log.d(TAG, "onBufferingStart UniversalVideoView callback");
                }

                @Override
                public void onBufferingEnd(MediaPlayer mediaPlayer) {// steam end loading
                    Log.d(TAG, "onBufferingEnd UniversalVideoView callback");
                }

            });

Database – Firebase or Own Server

Actually it based on your requirements. Because I don’t know about your demands, if you are just try test the application then SQLite is best otherwise go for Firebase or own web server. Most of peoples are earning money via apps development in play store. For example we have to filter some technology videos and then create one separate application. Some users are looking for specific application to browse similar videos. So for that this application is best & buy own server to store your files.

Also Read – Python Projects Free Source Code

Source Code – Video View Android

I hop above all source code and images are helps to find overall project objective. For more just test on your laptop and check customization works like views, modules, page forms, buttons, navigation etc. You can contact us on any time if you are facing any technical issues.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.