Android Archives - VdoCipher Blog https://www.vdocipher.com/blog/category/android/ Secure Video Streaming Tue, 09 Jul 2024 14:11:02 +0000 en-US hourly 1 https://wordpress.org/?v=6.4.5 https://www.vdocipher.com/blog/wp-content/uploads/2016/11/cropped-VdoCipher-logo2-32x32.png Android Archives - VdoCipher Blog https://www.vdocipher.com/blog/category/android/ 32 32 Media3 ExoPlayer Tutorial: How to Stream Videos Securely on Android? https://www.vdocipher.com/blog/exoplayer/ Tue, 02 Jan 2024 07:48:12 +0000 https://www.vdocipher.com/blog/?p=12004 Streaming videos securely on Android can be a bit challenging, but it can be easily done with Exoplayer! When it comes to streaming videos on Android, Exoplayer can be your go-to media player. It is even used by Google apps such as YouTube and Google TV. Exoplayer allows a lot of customization which enables its […]

The post Media3 ExoPlayer Tutorial: How to Stream Videos Securely on Android? appeared first on VdoCipher Blog.

]]>
Streaming videos securely on Android can be a bit challenging, but it can be easily done with Exoplayer!

When it comes to streaming videos on Android, Exoplayer can be your go-to media player. It is even used by Google apps such as YouTube and Google TV. Exoplayer allows a lot of customization which enables its adoption for various use cases.  Its support of media formats is also very wide, including adaptive streaming formats such as HLS, Dash, and Smooth Streaming. With its support for widevine, you can ensure that your content remains safe

What is an ExoPlayer?

ExoPlayer is an open-source media player for Android maintained by Google. It is not part of the Android framework and is distributed separately from the Android SDK. With ExoPlayer, you can easily take advantage of new features as they become available by updating your app.

ExoPlayer is the best alternative to android’s built-in MediaPlayer API which is used to control the playback of audio/video files and streams. It supports various features such as Dynamic Adaptive Streaming over HTTP(DASH), HTTP Live Streaming(HLS), Smooth Streaming, and Common Encryption. It can be used to play audio as well as video streaming online directly from the server and/or offline(locally) by downloading. It can be easily customized and extended. We can add features like captions, speed control, forward, rewind, etc. to the player. Exoplayer also provides a feature for encrypting the media playback (both online and offline) for secure streaming. It does not work on the device below API level 16.

Let’s see what Exoplayer has to offer and why or when we should use it over the built-in MediaPlayer API.

What are the Advantages of Using Exoplayer?

ExoPlayer has a number of advantages over Android’s built-in MediaPlayer:

  • There are fewer device-specific issues and less variation in behavior across different Android versions and devices with ExoPlayer.
  • You can update the player along with your application. Since ExoPlayer is a library included in your application, you can choose which version to use and easily update to a newer version. To ensure your application are developed and run smoothly, use the Docker platform.
  • You can customize and extend it to meet your needs. A lot of ExoPlayer components can be replaced with custom implementations since it was designed specifically with this in mind.
  • ExoPlayer has in-built support for playlists.
  • The Exoplayer supports a variety of formats in addition to DASH and SmoothStreaming. Additionally, it supports advanced HLS features such as handling #EXT-X-DISCONTINUITY tags and the ability to seamlessly merge, concatenate, and loop media streams.
  • On Android 4.4 (API level 19) and higher, it supports Widevine common encryption. Although the actual widevine support varies from device and is usually only available starting from Android 5. Sometimes, older devices with Android 5 and 6 can also get revoked due to security updates.
  • It is possible to integrate with a number of additional libraries quickly by using official extensions. For example, by using the Interactive Media Ads SDK, you can easily monetize your content with the IMA extension.

Explore More ✅

Stream Your Content Securely On Android With VdoCipher

VdoCipher helps provide end-to-end solutions for video, right from hosting, encoding, and encryption to the player. On top of it, you get APIs to manage videos, players, and more.

How To Implement Exoplayer in Android with examples?

We will create a simple exoplayer application to play a video using MediaItem.

The steps to implement Exoplayer are as follows:

  1. Add exoplayer dependencies in your app level build.gradle
    implementation 'com.google.android.exoplayer:exoplayer-core:2.18.0'
    implementation 'com.google.android.exoplayer:exoplayer-dash:2.18.0'
    implementation 'com.google.android.exoplayer:exoplayer-hls:2.18.0'
    implementation 'com.google.android.exoplayer:exoplayer-ui:2.18.0'
  1. Add SimpleExoPlayerView in layout file A SimpleExoPlayerView can be included in the layout for an Activity belonging to a video application as follows:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<com.google.android.exoplayer2.ui.SimpleExoPlayerView 
    android:id="@+id/exoPlayerView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

</FrameLayout>
  1. Create and load the player In your Activity, create an instance of Exoplayer and add it to the SimpleExoPlayerView
    MediaItem represents a media which can be added to the player at the time of preparation. After the player is prepared you can set set setPlayWhenReady to start the playback when media is ready.
SimpleExoPlayerView playerView = findViewById(R.id.exoPlayerView);
ExoPlayer player = new ExoPlayer.Builder(context).build();
// Bind the player to the view.
playerView.setPlayer(player);
// Create and add media item
MediaItem mediaItem = MediaItem.fromUri(video_url);
player.addMediaItem(mediaItem);
// Prepare exoplayer
player.prepare();
// Play media when it is ready
player.setPlayWhenReady(true);
  1. Handling the player controls Methods on the player can be called to control the player. Below are some of the methods:
  • play and pause: Used to play and pause the video
  • seekTo: Seeks to a position specified in milliseconds in the current MediaItem
  • playWhenReady: Whether playback should proceed when ready
  • hasNextMediaItem, hasPreviousMediaItem, seekToPreviousMediaItem, seekToNextMediaItem: Allows navigating through the playlist
  • setPlaybackParameters: Attempts to set the playback parameters.Playback parameters changes may cause the player to buffer. Player.Listener.onPlaybackParametersChanged(PlaybackParameters) will be called whenever the currently active playback parameters change
  1. Release the player Use ExoPlayer.release method to release the player after when it is no longer required.
if (exoPlayer != null) {
    exoPlayer.release();
}

How to Customize Exoplayer?

ExoPlayer comes with many customizations available such as UI adjusting to match your app, deciding caching mechanism for data loaded from the network, customizing server interaction to intercept HTTP requests and responses, customizing error handling policy, enabling asynchronous buffer queueing, and many more. In this section, we will look at how we can customize UI with ExoPlayer.

Customizing ExoPlayer’s UI components

ExoPlayer V2 includes several out-of-the-box UI components for customization, most notably:

  • SimpleExoPlayerView is a high level view for SimpleExoPlayer media playbacks. It displays video, subtitles and album art during playback, and displays playback controls using a PlaybackControlView.
  • PlaybackControlView is a view for controlling ExoPlayer instances. It displays standard playback controls including a play/pause button, fast-forward and rewind buttons, and a seek bar.

Use of this view is optional. You are free to implement your own UI components by yourself at the cost of some extra work. The SimpleExoPlayerView displays video, subtitles, and album art during playback, and displays playback controls using a PlaybackControlView.

A SimpleExoPlayerView can be customized by setting attributes (or calling corresponding methods), overriding the view’s layout file or by specifying a custom view layout file, as mentioned below.

Setting attributes for SimpleExoPlayerView

A SimpleExoPlayerView can be included in the layout for an Activity belonging to a video application as follows

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<com.google.android.exoplayer2.ui.SimpleExoPlayerView 
    android:id="@+id/player"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

</FrameLayout>

Now you can use following attributes on SimpleExoPlayerView to customize it when used in a layout XML file.

  • use_artwork – Whether artwork is used if available in audio streams.
  • default_artwork – Default artwork to use if no artwork available in audio streams.
  • use_controller – Whether the playback controls can be shown.
  • hide_on_touch – Whether the playback controls are hidden by touch events.
  • auto_show – Whether the playback controls are automatically shown when playback starts, pauses, ends, or fails. If set to false, the playback controls can also be manually operated with showController() and hideController().
  • resize_mode – Controls how video and album art is resized within the view. Valid values are fit, fixed_width, fixed_height and fill.
  • surface_type – The type of surface view used for video playbacks. Valid values are surface_view, texture_view and none. Using none is recommended for audio only applications, since creating the surface can be expensive. Using surface_view is recommended for video applications.
  • shutter_background_color – The background color of the exo_shutter view.
  • player_layout_id – Specifies the id of the layout to be inflated.
  • controller_layout_id – Specifies the id of the layout resource to be inflated by the child PlaybackControlView.

Overriding the view’s layout file

To customize the layout of SimpleExoPlayerView throughout your app, or just for certain configurations, you can define exo_simple_player_view.xml layout files in your application res/layout* directories. These layouts will override the one provided by the ExoPlayer library, and will be inflated for use by SimpleExoPlayerView. The view identifies and binds its children by looking for the following ids:

  • exo_content_frame – A frame whose aspect ratio is resized based on the video or album art of the media being played, and the configured resize_mode. The video surface view is inflated into this frame as its first child. Type AspectRatioFrameLayout
  • exo_shutter – A view that’s made visible when video should be hidden. This view is typically an opaque view that covers the video surface view, thereby obscuring it when visible. Type: View
  • exo_subtitles – Displays subtitles. Type: SubtitleView
  • exo_artwork – Displays album art. Type: ImageView
  • exo_controller_placeholder – A placeholder that’s replaced with the inflated PlaybackControlView. Ignored if an exo_controller view exists. Type: View
  • exo_controller – An already inflated PlaybackControlView. Allows use of a custom extension of PlaybackControlView. Note that attributes such as rewind_increment will not be automatically propagated through to this instance. If a view exists with this id, any exo_controller_placeholder view will be ignored. Type: PlaybackControlView
  • exo_overlay – A FrameLayout positioned on top of the player which the app can access via getOverlayFrameLayout(), provided for convenience. Type: FrameLayout

Any child views are optional, but where defined they must be of the expected type.

Specifying a custom layout file

Defining your own exo_simple_player_view.xml is useful to customize the layout of SimpleExoPlayerView throughout your application. It’s also possible to customize the layout for a single instance in a layout file. This can be achieved by setting the player_layout_id attribute on a SimpleExoPlayerView. This make specified layout inflated instead of exo_simple_player_view.xml for only the instance on which the attribute is set.

For more customization option check official document on customizing ExoPlayer.

Changing Video Quality in ExoPlayer on Android

To change the video quality in ExoPlayer, developers can utilize TrackSelector and DefaultTrackSelector. They can create a DefaultTrackSelector, configure it with desired parameters like bitrate, and then pass it to the ExoPlayer instance during initialization​.

Changing ExoPlayer Aspect Ratio

Developers can set the aspect ratio of the ExoPlayer by creating a custom AspectRatioFrameLayout and wrapping it around the PlayerView. They can then use the setAspectRatio method on the AspectRatioFrameLayout to change the aspect ratio.

Implementing ExoPlayer Cache

Caching can be implemented in ExoPlayer by using the CacheDataSourceFactory which wraps around another DataSource.Factory instance. A SimpleCache instance can be used to manage the cache, and the LeastRecentlyUsedCacheEvictor can be used to evict old data from the cache to ensure it doesn’t grow too large​.

ExoPlayer Play Audio from URL

To play audio from a URL, developers can initialize a DefaultDataSourceFactory and a ProgressiveMediaSource (or other appropriate MediaSource depending on the audio format), and prepare the ExoPlayer instance with the MediaSource. The uri of the audio file needs to be passed to the MediaSource to start streaming and playing the audio.

ExoPlayer Play Local File

Playing a local file can be achieved by creating a MediaItem or a RawResourceDataSource with the URI of the local file, and then preparing the ExoPlayer instance with a MediaSource created with that URI. Developers can use the res/raw folder to store and access local files, or use the assets directory if the file is stored there. They can use methods like RawResourceDataSource.buildRawResourceUri or MediaItem.fromUri to create a URI from the local file path

How To Play DRM Content On Exoplayer

So far we have gone through the advantages of using ExoPlayer and how to customize it to suit our needs, in this section, we will see how to use ExoPlayer to play DRM-protected content which is also mentioned as its advantage over the in-built MediaPlayer API.

Before we start lets understand what is Digital rights management (DRM). Digital rights management (DRM) is way to protect copyrights for digital media. It has been developed to protect all kinds of digital materials prepared for computers and other technological devices, including movies, tv series, games, music and software. Putting these restrictions on DRM-protected content is creating security issues that prevent copying and distribution over the internet.

ExoPlayer uses Android’s Media Drm API to support DRM protected playbacks.

The minimum Android versions required for different supported DRM schemes, along with the streaming formats for which they’re supported are the following. In addition to the below table, playback is limited on older devices due to security updates. Android version 7 and above are more reliable to widevine playback.

While building a media source for ExoPlayer, you should specify the UUID of the DRM system and the license server URI. Using these properties we will build an instance of DefaultDrmSessionManager needed for handling DRM related key and provisioning request to enable media playback.

Frist we need to create a instance of DrmSessionManager

private DefaultDrmSessionManager buildDrmSessionManager(UUID uuid, String licenseUrl, String userAgent) {  
    HttpDataSource.Factory licenseDataSourceFactory = new DefaultHttpDataSource.Factory().setUserAgent(userAgent);  
    HttpMediaDrmCallback drmCallback = new HttpMediaDrmCallback(licenseUrl, true,  
            licenseDataSourceFactory);  
    return new DefaultDrmSessionManager.Builder()  
            .setUuidAndExoMediaDrmProvider(uuid, FrameworkMediaDrm.DEFAULT_PROVIDER)  
            .build(drmCallback);  
}

Now we have to build a media source with license url

DRM License Url : https://proxy.uat.widevine.com/proxy?provider=widevine_test

private DashMediaSource buildDashMediaSource(Uri uri) {  
    String drmLicenseUrl = "https://proxy.uat.widevine.com/proxy?provider=widevine_test";  
    String userAgent = Util.getUserAgent(context, context.getApplicationContext().getPackageName());  
    UUID drmSchemeUuid = Util.getDrmUuid(C.WIDEVINE_UUID.toString());  

    DrmSessionManager drmSessionManager = buildDrmSessionManager(drmSchemeUuid, drmLicenseUrl, userAgent);  

    DataSource.Factory dataSourceFactory = new DefaultDataSource.Factory(context, new DefaultHttpDataSource.Factory().setUserAgent(userAgent));  
    return new DashMediaSource.Factory(dataSourceFactory)  
            .setDrmSessionManagerProvider(unusedMediaItem -> drmSessionManager)  
            .createMediaSource(  
                    new MediaItem.Builder()  
                            .setUri(uri)  
                            .setMimeType(MimeTypes.APPLICATION_MPD)  
                            .build()  
            );  
}

Now add url and its ready to be played.

DRM Url: https://storage.googleapis.com/wvmedia/cenc/h264/tears/tears.mpd

private void initializePlayer() {  
    String url = "https://storage.googleapis.com/wvmedia/cenc/h264/tears/tears.mpd";  

    MediaSource mediaSource = buildDashMediaSource(Uri.parse(url));  

    ExoTrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory();  
    TrackSelector trackSelector = new DefaultTrackSelector(context, videoTrackSelectionFactory);  
    trackSelector.setParameters(trackSelector.getParameters().buildUpon()  
            .setPreferredTextLanguage("en")  
            .build());  

    DefaultRenderersFactory renderersFactory = new DefaultRenderersFactory(context)  
            .forceEnableMediaCodecAsynchronousQueueing()  
            .setExtensionRendererMode(DefaultRenderersFactory.EXTENSION_RENDERER_MODE_OFF);  

    int maxBufferMs = DefaultLoadControl.DEFAULT_MAX_BUFFER_MS;  

    DefaultLoadControl loadControl = new DefaultLoadControl.Builder()  
            .setBufferDurationsMs(DefaultLoadControl.DEFAULT_MIN_BUFFER_MS,  
                    maxBufferMs,  
                    DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_MS,  
                    DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS)  
            .build();  

    ExoPlayer exoPlayer = new ExoPlayer.Builder(context, renderersFactory)  
            .setTrackSelector(trackSelector)  
            .setLoadControl(loadControl)  
            .build();  

    exoPlayer.setMediaSource(mediaSource);  
    exoPlayer.prepare();  
}

In next section we will see how we at VdoCipher use ExoPlayer to stream DRM protected videos.

Adaptive Bitrate Streaming in Exoplayer

Exoplayer can also be used for adaptive bitrate streaming to set video quality automatically based on available network bandwidth. Adaptive bitrate streaming (also known as adaptive streaming) is a technology designed to deliver video in the most efficient way possible and in the highest usable quality for each specific user and device.

For slow connections, the video will be played in low quality, and for fast connections, the video will be played in the best quality with less buffer time. These qualities(bit rates and resolutions) are known as tracks. The same media content is split into multiple tracks, each for a given quality based on bit rate and resolution. Each track is split into chunks of a given duration, typically between 2 and 10 seconds. This makes it easier to switch between tracks with changing network speeds and signals.

Implementing Adaptive Track Selection

To implement Adaptive streaming, add TrackSelector while initializing the player. The TrackSelector is used to switch between multiple tracks.

ExoTrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory();

TrackSelector trackSelector = new DefaultTrackSelector(context, videoTrackSelectionFactory);  
trackSelector.setParameters(trackSelector.getParameters().buildUpon()
        .setMaxVideoSizeSd()  
        .setPreferredTextLanguage("en")  
        .build());  

ExoPlayer exoPlayer = new ExoPlayer.Builder(context)  
        .setTrackSelector(trackSelector)  
        .build();  

Create an adaptive track selection factory with default parameters and pass it to DefaultTrackSelector which is responsible for choosing tracks in the media item.
Then pass the trackSelector to ExoPlayer builder.

Build an Adaptive Media Source

DASH, HLS, and SmoothStreaming are all media formats ExoPlayer supports that are capable of adaptive streaming, but we’ll focus on DASH for now and use the DashMediaSource. To stream DASH content, you need to create a MediaItem.

Uri manifestUri = Uri.parse(dashUrl); 
DataSource.Factory dataSourceFactory = new DefaultDataSource.Factory(context, new DefaultHttpDataSource.Factory().setUserAgent(userAgent));
mediaSource = new DashMediaSource.Factory(dataSourceFactory)
                    .createMediaSource(
                            new MediaItem.Builder()
                                .setUri(manifestUri)
                                .setMimeType(MimeTypes.APPLICATION_MPD)
                                .build()
                    );

How VdoCipher Streams Video on Android Using ExoPlayer

The components of our video streaming can be broken down into four main parts:

  1. Client attempting to play content
  2. VdoCipher license server that generates decryption keys based on client requests
  3. Provisioning server if unique credentials are required for devices
  4. Content server that serves encrypted content

At client side we try to play protected content from the content server via a DashMediaSource with a provided DrmSessionManager, this DRMSessionManager contains the implementation of MediaDRMCallback wrapping a HttpMediaDrmCallback that extends its functionality by wrapping/unwrapping license request/response and throwing custom exceptions to help identify the cause. In the meantime, if the device needs provisioning, a request to the provisioning server is done via callback. After the MediaDRM client receives the license, and it is passed to ExoPlayer via the media source and media playback will begin. This procedure is repeated with every media playback request for non-persistent licenses. Our application saves persistent licenses and reuses them until they expire. In addition, persistent license requests are fetched before the secure video playback starts with OfflineLicenseHelper, allowing for video initialization to happen regardless of whether or not the license fetch operation succeeded. Now lets see how these classes are utilized.

How Exoplayer can play video from URL in Android video player?

After creating the instance of Exoplayer you can pass the video_url as, MediaItem mediaItem = MediaItem.fromUri(video_url);

You can also stop playback on cloned apps, emulators and rooted devices in Android with our Play Integrity integration in Android SDK. Check out our play integrity api documentation to know more. Learn more about android video SDK to stream your videos on Android with VdoCipher.

The post Media3 ExoPlayer Tutorial: How to Stream Videos Securely on Android? appeared first on VdoCipher Blog.

]]>
Best Video Player for Android Comparison 2024 https://www.vdocipher.com/blog/top-video-player-for-android/ Tue, 26 Dec 2023 11:28:19 +0000 https://www.vdocipher.com/blog/?p=15497 Media player with multimedia capabilities is one of the important features in today’s smartphones. Most of the video content is consumed on smart devices and viewers continue their tasks like sending emails, surfing apps keeping the video playback on through Picture-in-Picture mode. Playing audio/video on an Android app has become a basic function with android […]

The post Best Video Player for Android Comparison 2024 appeared first on VdoCipher Blog.

]]>
Media player with multimedia capabilities is one of the important features in today’s smartphones. Most of the video content is consumed on smart devices and viewers continue their tasks like sending emails, surfing apps keeping the video playback on through Picture-in-Picture mode. Playing audio/video on an Android app has become a basic function with android video players becoming more and more customizable. Some of the best video players for Android offer multi format support, easy customizations, hardware acceleration, subtitle support and much more. In this blog, we have compared the best video player for Android based on speed, battery consumption, streaming capabilities, resource usage and more.

Comparing top video player for Android

VLC for Android

VLC media player is a cross-platform open source multi-media player. VLC for Android supports audio and video playback as well as network streams, DVD ISOs, network shares and drivers. It is similar to the desktop version of VLC.

Rating & Reviews – 4.2, 1.7M reviews

“Excellent app but the only thing that I found bugging me is that in some long videos (~2h-3hr) we can not jump to a certain position and the video automatically stops playing. Even if we play video from the beginning and when it reaches this certain point, it stops playing. I even tried to change h/w acceleration options but it didn’t work. Hope this gets fixed asap.”Play Store review

Explore full potential of your videos with ExoPlayer advance features, adaptive streaming, extensive format support, and customizable playback options.

MX Player: Video Player & OTT

MX Player supports all popular video formats and offers MX Silver Ad-Lite subscription. MX Player app supports seamless 8K / 4K Ultra HD / HD video playback. Additionally , you get access to a vast collection of free multilingual movies, TV shows, MX Originals, music videos, and much more.

Rating & Reviews – 4, 12.3M reviews

“Best app, Add 1.25 speed on video player”Play Store review

BSPlayer

BSPlayer is a hardware accelerated video player, suited for older Android devices. It supports multi-core (dual and quad-core) HW decoding and it’s also known for its automatic subtitle finding functionality.

Rating & Reviews – 4, 145K reviews

“Used this app for the past decade but now Too many ads, switched to VLC”Play Store review

Kodi

Kodi is an open-source software media player for digital media for Home Theatre PCs (HTPCs). It’s ideal for users who want to integrate their video, music, and gaming experiences in one platform.

Rating & Reviews – 3.2, 328k reviews

“Powerful app. Has a lot of features and functionalities and still runs smooth. Can not only convert your phone to a server can also act as an intermediate device to boost functionalities of other devices. Like if your router only has ftp or smb can use this phone as a upnp middle man. Lots of other stuff too.”Play Store review

KMPlayer – All Video Player

KMPlayer caters to all forms of HD videos, music and subtitle files. Features include bookmark, quick button, chromecast support, and play speed settings.

Rating & Reviews – 3.6, 388K reviews

“Impressive. First app giving all the desired options after over 10 attempts with other players. Flawless. Good songs management, can play in background without blocking the screen, sound amplifier… even cool options like wifi broadcast. Probably the BEST AND MOST USEFUL app on google play.”Play Store review

XPlayer (Video Player All Format)

XPlayer is a highly popular online video player, supporting all video formats and 4K/Ultra HD video files. The player supports password for your private album and Night Mode, Quick Mute & Playback Speed.

Rating & Reviews – 4.7, 1.56M reviews

“Have been using this video player app for a while now, and it’s been a bit of a mixed bag. On the positive side, all my videos play seamlessly, and the interface is user-friendly. However, I’ve encountered an issue with song detection. Not all my songs are being picked up by the app, which can be frustrating when I want to create playlists including both videos and music. I appreciate the smooth video playback, but I hope the developers can address the song detection issue in future updates.”Play Store review

Feature/Factor VLC for Android MX Player BSPlayer Kodi KMPlayer XPlayer
Speed Fast Very Fast Moderate Variable Fast Very Fast
Resource Usage Moderate Moderate-High Low High Moderate-High Moderate
Battery Consumption Efficient Moderately Efficient Very Efficient Less Efficient Moderately Efficient Efficient
Format Support Extensive Extensive Good Extensive Extensive Extensive
UI/UX User-Friendly Highly Intuitive Basic Customizable User-Friendly Intuitive
Subtitle Support Excellent Advanced Good Excellent Good Excellent
Streaming Capability Good Good Moderate Excellent Good Good
Additional Features Wide Range Gesture Control, Kids Lock Lightweight Media Center Features Cloud Integration Night Mode, Privacy Folders

Must have features in a custom video player for Android App

Multi-Format Support – support for various video formats (FLV, MKV, MP4 and AVI) and codecs. This ensures video availability and playback on a variety of video files on devices.

Adaptive Streaming – adaptive streaming auto adjusts the video quality as per the viewer’s internet speed, thus ensuring smooth playback. The video player has to support adaptive streaming protocols like DASH and HLS.

User-Friendly Interface – The player must have an easy to navigate and intuitive interface. This improves the viewing experience and accessibility for the viewers.

Responsive and Efficient Playback Controls – Various controls like play, pause, seek must be responsive and smooth, giving the viewer complete control over the video playback.

Subtitle Support – subtitle support makes the content accessible to non-native speakers and people who are deaf or hard of hearing. The player should have support for various subtitle formats.

Hardware Acceleration – This involves utilizing the device hardware tor video decoding, which improves the performance. High-resolution videos have a smooth playback and at the same time, battery life is conserved.

Customizable Playback Speed – Without disturbing the audio quality, the player must have the option to alter playback speed. It is highly useful in education videos or watching videos at preferred speeds.

Aspect Ratio and Zoom Controls – changing aspect ratio and zoom in/out allows viewers to adjust the video display as per their preference or screen size.

Error Handling and Reporting – There will be instances of playback errors and a proper clarification and potential solution should be displayed to the viewer.

Security and DRM Support – VdoCipher custom video player for Android offers the highest level of video security i.e, DRM support to protect copyrighted content and ensure compliance.

Analytics and Reporting – Gathering data on viewer’s viewing behavior and preferences make it easy to improve and personalize their viewing experience.

Integrations – with Native, Flutter, React Native SDK

Offline download & playback – Ability to support offline download and secure playback.

Play Integrity Integration – To prevent app cloning and prevent hacking attempts. Check out our play integrity apk documentation to know more.

Picture in Picture Option – multi-window mode to shrink a video to a small player so that you can keep using other apps on your smartphone.

Background playback possibility – play videos in background

Creating custom video player for Android

Most developers, while creating a custom video player for Android, rely on two primary options provided by Google, MediaPlayer and ExoPlayer. MediaPlayer is a customizable open source library, part of android SDK and suited for simple playback video requirements. On the other hand, ExoPlayer offers more features and flexibility. Developers use it for advanced features like adaptive streaming.

MediaPlayer

The framework supports various common media type playbacks, allowing easy integration of images, video and audio into your applications. Audio and video media files stored in application’s resources can be played from standalone files or using MediaPlayer APIs to play from a data stream arriving over a network connection. MediaPlayer is easy to integrate, making it a popular choice for developers who do not need extensive customizations.

With Android Native SDK by VdoCipher, integrate DRM security and watermarking features into your app

Following classes are used to play sound and videos in the Android framework:

  • MediaPlayer – primary API to play sound and video. It supports various media sources such as Local resources, Internal URIs and External URLs (streaming)
  • AudioManager – manages audio sources and audio output on a device

MediaPlayer has limited support for adaptive streaming protocols like HLS or DASH and doesn’t provide as much control over buffering, rendering, and track selection.

Media3 ExoPlayer

Jetpack Media3 has a Player Interface which defines basic functionalities such as pause, play, seek and display track information. The default implementation of this interface in Media3(a powerful media playback library by Google ) is ExoPlayer. Compared to MediaPlayer, it provides support for multi streaming protocols, default media renderers, and components to handle media buffering. ExoPlayer is highly customizable and can be updated via Play Store application updates.

  • Add ExoPlayer as a dependency to your project.
  • Create an ExoPlayer instance.
  • Attach the player to a view (for video output and user input).
  • Prepare the player with a MediaItem to play.
  • Release the player when done.

Comparison between MediaPlayer and ExoPlayer Framework

Feature/Aspect MediaPlayer ExoPlayer
Library Type Part of Android SDK Standalone, open-source library
Ease of Use Simple to use for basic requirements More complex, but offers greater flexibility and control
Supported Formats Standard formats like MP4, MP3, AAC Extensive format support including MP4, MP3, AAC, MKV, FLV, HLS, DASH
Adaptive Streaming Limited support Full support for adaptive streaming protocols like HLS, DASH
Customization Limited customization options Highly customizable with component replacement and extension
Performance Generally good for basic use cases Optimized for both simple and advanced use cases
Resource Usage Lower resource usage Higher resource usage due to advanced features
Device Compatibility Good across different Android versions and devices Consistent performance across different Android versions and devices
Community Support Standard Android SDK support Strong community support and regular updates from Google
Use Case Examples – Playing background music in apps<br>- Simple video playback in apps – Video streaming apps<br>- Apps requiring customized playback control
Development Less development time for standard functionalities More development time but offers advanced features
Updates Dependent on Android SDK updates Regularly updated independently of Android SDK
DRM Support Basic DRM support Robust DRM support and easy integration with DRM solutions
Hardware Acceleration Supported but less configurable Extensive support and configurable hardware acceleration

VdoCipher Security and DRM in video players for Android

VdoCipher has mastered the art of delivering encrypted video content to Android devices, leveraging the power of ExoPlayer/Media3. Let’s dive into the four key components that make this possible:

  • The Client’s Role – At the heart of the process is the client, eagerly attempting to play content. This is where the user’s journey begins.
  • VdoCipher’s License Server – This is the brains of the operation. The license server responds to client requests by generating decryption keys, ensuring that only authorized users can access the content.
  • Provisioning for Unique Credentials – Some scenarios require unique credentials for specific devices. Here, a provisioning server steps in to ensure that each device gets what it needs for a seamless streaming experience.
  • The Content Server – The final piece of the puzzle is the content server, which safely serves the encrypted content to the client.

Now, let’s look at how these components interact at the client-side

  • Playing Protected Content – The client attempts to play protected content from the content server. This is done using a DashMediaSource, paired with a DrmSessionManager.
  • The Role of DRMSessionManager – The DRMSessionManager, a pivotal element, implements the MediaDRMCallback. It’s further enhanced by the HttpMediaDrmCallback, which adds layers of functionality, such as wrapping/unwrapping license requests and responses, and throwing custom exceptions to pinpoint issues.
  • Device Provisioning – If a device needs provisioning, a request is made to the provisioning server. This is seamlessly handled via a callback.
  • License Acquisition and Playback – Once the MediaDRM client secures the license, it’s passed to ExoPlayer, kickstarting media playback. This process is a must for each media playback request, especially for non-persistent licenses.
  • Handling Persistent Licenses – The application smartly saves and reuses persistent licenses until they expire. Plus, persistent license requests are pre-fetched before video playback begins, using OfflineLicenseHelper. This ensures video initialization is smooth, regardless of the success of the license fetch operation.

FAQs

What is the best video player for Android?

Some of the best-rated video player for Android based on customer reviews are MX Player, VLC for Android, and ExoPlayer.

Is MX Player allowed in India?

Yes, MX Player services are accessible in India.

Is VLC better than MX Player?

Each of these Android video players have their own strengths and weaknesses. Some reddit reviews find MX Player having better customizations and preference for pc, laptop unlike VLC which is recommended by many for smartphones.

Can the interface of Android video players be customizable?

Video players for Android like VdoCipher custom video player offer a high level of customizations like theme and layout change.

Do video player for Android have adaptive streaming?

VdoCipher video player supports adaptive bitrate streaming which means the video quality dynamically adjusts based on the viewer’s internet connection and playback device. The feature is highly useful in times of low internet connectivity or for those living in tier 2,3 cities. Learn more about VdoCipher’s Android video SDK  for adaptive streaming

References:

https://developer.android.com/guide/topics/media/platform/mediaplayer

https://developer.android.com/guide/topics/media/exoplayer

The post Best Video Player for Android Comparison 2024 appeared first on VdoCipher Blog.

]]>
VdoCipher Android SDK Features Update https://www.vdocipher.com/blog/new-android-sdk-features-update/ Thu, 21 Jul 2022 17:53:50 +0000 https://www.vdocipher.com/blog/?p=11728 We are happy to inform you about major updates to our Android Native and React Native SDK to provide new cool features. Android Native SDK: Exoplayer version upgrade – Upgraded Exoplayer dependency to the latest version 2.18.0. Android Native SDK Doc, latest version 1.12.1. Android Video SDK Picture in Picture – You can also implement Picture […]

The post VdoCipher Android SDK Features Update appeared first on VdoCipher Blog.

]]>
We are happy to inform you about major updates to our Android Native and React Native SDK to provide new cool features.

Android Native SDK:

  • Exoplayer version upgrade – Upgraded Exoplayer dependency to the latest version 2.18.0.
    Android Native SDK Doc, latest version 1.12.1. Android Video SDK

  • Picture in Picture – You can also implement Picture in Picture mode in your app with our player by following the documentation presented here.

  • Auto-Resume – While generating the embed info for a video, the user can also pass the flag enableAutoResume (default: false), to enable the auto-resume of the video playback from the last watched position. The documentation is here at the end of this doc.

  • Search in the caption – You can search the text in the selected closed caption to seek to a position of the desired sentence or word. The offline playback also has an option to use and search in captions now.

  • Offline download new setup – We are now using Exoplayer’s download APIs to download and play videos offline which will in turn reduce the errors faced while downloading videos.

  • Offline download in external storage – The content can now be downloaded in external storage(for example – SD card) and download notifications can be customized at your end. The details can be found here and here.

  • Caption language – You can set the default caption language for a video. 

  • Common Error Codes Documented – You can also refer to the link here to see all the Error Codes and their descriptions.

Android React Native SDK:

  • Latest Version updated to Latest version: 1.8.1.

  • New Documentation –  We have updated the documentation for react-native SDK to have a more detailed description that can be found here for React Native SDK.

  • Auto-resume – You can also auto-resume playback from the time till when you last watched a video. Documentation: React native video SDK.

  • Custom player controls – We have also added the documentation to add custom controls in the player which can be found here.

  • Fullscreen – You can now toggle the full-screen of the player embedded in JS code using custom or native controls by following the documentation present here.

  • The other features added in native SDK will also be implemented in the react-native SDK in some time.

A note for our users:

While we rigorously tested these features internally and with our initial Beta users, there could be still some clarification/improvement required. You can share your feedback and if any issues are encountered by just writing us at support@vdocipher.com.

FAQs

How can I enable Picture in Picture (PiP) mode in my app?

Ensure your activity supports PiP mode in the manifest file, use setPictureInPictureSupport(true) on VdoPlayerUIFragment, and handle UI changes when the app enters or exits PiP mode.

How does offline video download and playback work?

From SDK version 1.13.0, videos can be saved offline without the need for continuous internet connectivity, but the internet is required for playback authentication. The SDK from version 1.17.0 allows passing a persistent OTP for downloading videos.

How can I ensure my app only plays videos on genuine physical devices?

Implement SafetyNet via Google APIs to enhance emulator protection and optionally block devices with ADB debugging enabled for higher security.

What steps should be taken to handle orientation changes in my app?

Override config changes in your AndroidManifest.xml and use onConfigurationChanged in your activity to manage UI elements during orientation changes.

Are there any ProGuard rules specific to VdoCipher SDK?

Yes, ProGuard rules to keep VdoCipher and associated MediaLibraryInfo classes are necessary to ensure proper functionality of the SDK.

The post VdoCipher Android SDK Features Update appeared first on VdoCipher Blog.

]]>