Convert Figma logo to code with AI

brianwernick logoExoMedia

An Android ExoPlayer wrapper to simplify Audio and Video implementations

2,138
378
2,138
21

Top Related Projects

21,714

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media

VLC for Android, Android TV and ChromeOS

32,488

Android/iOS video player based on FFmpeg n3.4, with MediaCodec, VideoToolbox support.

视频播放器(IJKplayer、ExoPlayer、MediaPlayer),HTTPS,16k page size,支持弹幕,外挂字幕,支持滤镜、水印、gif截图,片头广告、中间广告,多个同时播放,支持基本的拖动,声音、亮度调节,支持边播边缓存,支持视频自带rotation的旋转(90,270之类),重力旋转与手动旋转的同步支持,支持列表播放 ,列表全屏动画,视频加载速度,列表小窗口支持拖动,动画效果,调整比例,多分辨率切换,支持切换播放器,进度条小窗口预览,列表切换详情页面无缝播放,rtsp、concat、mpeg。

MediaPlayer exoplayer ijkplayer ffmpeg

Infinite cycle ViewPager with two-way orientation and interactive effect.

Quick Overview

ExoMedia is an Android library that extends the ExoPlayer library, providing a simplified interface for media playback. It offers additional features and abstractions to make video and audio playback easier to implement in Android applications, with support for various media formats and streaming protocols.

Pros

  • Simplifies media playback implementation in Android apps
  • Supports a wide range of media formats and streaming protocols
  • Provides a consistent API across different Android versions
  • Offers customizable UI components for video playback

Cons

  • Adds additional dependencies to the project
  • May have a steeper learning curve for developers unfamiliar with ExoPlayer
  • Potential performance overhead compared to using ExoPlayer directly
  • Limited documentation and examples for advanced use cases

Code Examples

  1. Basic video playback:
val videoView = findViewById<VideoView>(R.id.video_view)
videoView.setMedia(Uri.parse("https://example.com/video.mp4"))
videoView.start()
  1. Setting up an audio player:
val audioPlayer = AudioPlayer(context)
audioPlayer.setMedia(Uri.parse("https://example.com/audio.mp3"))
audioPlayer.start()
  1. Customizing video controls:
val videoView = findViewById<VideoView>(R.id.video_view)
videoView.setControls(VideoControls(context).apply {
    setSeekListener { position -> /* Handle seek */ }
    setPlayPauseListener { playing -> /* Handle play/pause */ }
})
  1. Handling playback events:
videoView.setOnPreparedListener { /* Video is prepared */ }
videoView.setOnCompletionListener { /* Playback completed */ }
videoView.setOnErrorListener { e -> /* Handle error */ }

Getting Started

  1. Add the ExoMedia dependency to your app's build.gradle file:
dependencies {
    implementation 'com.github.brianwernick:ExoMedia:5.0.0'
}
  1. Add the ExoPlayer dependency:
dependencies {
    implementation 'com.google.android.exoplayer:exoplayer-core:2.18.1'
    implementation 'com.google.android.exoplayer:exoplayer-dash:2.18.1'
    implementation 'com.google.android.exoplayer:exoplayer-hls:2.18.1'
}
  1. Initialize ExoMedia in your Application class:
class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        ExoMedia.initialize(this)
    }
}
  1. Use VideoView or AudioPlayer in your layouts and activities as shown in the code examples above.

Competitor Comparisons

21,714

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media

Pros of ExoPlayer

  • Developed and maintained by Google, ensuring high-quality and regular updates
  • Extensive feature set, including support for various media formats and streaming protocols
  • Large community and extensive documentation

Cons of ExoPlayer

  • Steeper learning curve due to its comprehensive nature
  • May be overkill for simple media playback requirements
  • Larger library size compared to ExoMedia

Code Comparison

ExoPlayer:

val player = SimpleExoPlayer.Builder(context).build()
player.setMediaItem(MediaItem.fromUri(videoUri))
player.prepare()
player.play()

ExoMedia:

val videoView = findViewById<VideoView>(R.id.video_view)
videoView.setVideoURI(videoUri)
videoView.start()

ExoPlayer offers more granular control over the player instance, while ExoMedia provides a simpler API for basic video playback. ExoPlayer's approach allows for more customization and advanced features, but ExoMedia's implementation is more straightforward for simple use cases.

Both libraries serve different purposes: ExoPlayer is a full-featured media player for advanced requirements, while ExoMedia is a wrapper around ExoPlayer that simplifies its usage for basic media playback scenarios.

VLC for Android, Android TV and ChromeOS

Pros of VLC-Android

  • Comprehensive media player with support for a wide range of audio and video formats
  • Open-source project with a large community and active development
  • Includes advanced features like network streaming and subtitle support

Cons of VLC-Android

  • Larger codebase and more complex architecture, potentially harder to integrate
  • May include unnecessary features for projects requiring only basic media playback
  • Heavier resource usage due to its full-featured nature

Code Comparison

VLC-Android (Java):

MediaPlayer mediaPlayer = new MediaPlayer(this);
mediaPlayer.setMedia(new Media(libVLC, Uri.parse(url)));
mediaPlayer.play();

ExoMedia (Kotlin):

val videoView = findViewById<VideoView>(R.id.video_view)
videoView.setVideoURI(Uri.parse(url))
videoView.start()

VLC-Android offers more low-level control but requires more setup, while ExoMedia provides a simpler API for basic playback scenarios. ExoMedia is more focused on Android-specific implementations, whereas VLC-Android is part of a larger cross-platform project.

32,488

Android/iOS video player based on FFmpeg n3.4, with MediaCodec, VideoToolbox support.

Pros of ijkplayer

  • Cross-platform support (iOS, Android, macOS, Windows)
  • Based on FFmpeg, providing extensive codec and format support
  • Lower-level API for more fine-grained control

Cons of ijkplayer

  • More complex setup and integration process
  • Requires native code knowledge (C/C++) for advanced customization
  • Less actively maintained compared to ExoMedia

Code Comparison

ExoMedia (Kotlin):

val videoView = findViewById<VideoView>(R.id.video_view)
videoView.setVideoURI(Uri.parse("https://example.com/video.mp4"))
videoView.start()

ijkplayer (Java):

IjkMediaPlayer player = new IjkMediaPlayer();
player.setDataSource("https://example.com/video.mp4");
player.prepareAsync();
player.start();

Both libraries provide simple APIs for basic video playback, but ijkplayer offers more low-level control at the cost of increased complexity. ExoMedia builds upon ExoPlayer, providing a higher-level abstraction, while ijkplayer is closer to the underlying media playback mechanisms.

视频播放器(IJKplayer、ExoPlayer、MediaPlayer),HTTPS,16k page size,支持弹幕,外挂字幕,支持滤镜、水印、gif截图,片头广告、中间广告,多个同时播放,支持基本的拖动,声音、亮度调节,支持边播边缓存,支持视频自带rotation的旋转(90,270之类),重力旋转与手动旋转的同步支持,支持列表播放 ,列表全屏动画,视频加载速度,列表小窗口支持拖动,动画效果,调整比例,多分辨率切换,支持切换播放器,进度条小窗口预览,列表切换详情页面无缝播放,rtsp、concat、mpeg。

Pros of GSYVideoPlayer

  • More comprehensive feature set, including support for various video formats and streaming protocols
  • Extensive customization options for UI and player controls
  • Active development with frequent updates and bug fixes

Cons of GSYVideoPlayer

  • Steeper learning curve due to its extensive feature set
  • Larger library size, which may impact app size and performance
  • Documentation primarily in Chinese, which may be challenging for non-Chinese speakers

Code Comparison

ExoMedia:

val videoView = findViewById<VideoView>(R.id.video_view)
videoView.setVideoURI(Uri.parse(videoUrl))
videoView.start()

GSYVideoPlayer:

val videoPlayer = findViewById<StandardGSYVideoPlayer>(R.id.video_player)
videoPlayer.setUp(videoUrl, true, "Video Title")
videoPlayer.startPlayLogic()

Both libraries offer simple setup and playback, but GSYVideoPlayer provides more options for customization and control out of the box. ExoMedia focuses on simplicity and ease of use, while GSYVideoPlayer offers a more feature-rich experience at the cost of increased complexity.

MediaPlayer exoplayer ijkplayer ffmpeg

Pros of JiaoZiVideoPlayer

  • Simpler implementation for basic video playback needs
  • Better support for Chinese language and documentation
  • Includes a built-in UI with customizable controls

Cons of JiaoZiVideoPlayer

  • Less actively maintained compared to ExoMedia
  • Fewer advanced features and codec support
  • Limited compatibility with various streaming protocols

Code Comparison

JiaoZiVideoPlayer:

JzvdStd jzvdStd = findViewById(R.id.jz_video);
jzvdStd.setUp("http://jzvd.nathen.cn/c6e3dc12a1154626b3476d9bf3bd7266/6b56c5f0dc31428083757a45764763b0-5287d2089db37e62345123a1be272f8b.mp4"
              , "Title");
jzvdStd.posterImageView.setImage("http://p.qpic.cn/videoyun/0/2449_43b6f696980311e59ed467f22794e792_1/640");

ExoMedia:

VideoView videoView = findViewById(R.id.video_view);
videoView.setVideoURI(Uri.parse("http://example.com/video.mp4"));
videoView.setOnPreparedListener(() -> videoView.start());

Both libraries offer simple ways to set up video playback, but JiaoZiVideoPlayer includes more built-in UI elements, while ExoMedia focuses on core functionality and flexibility.

Infinite cycle ViewPager with two-way orientation and interactive effect.

Pros of InfiniteCycleViewPager

  • Specialized for infinite cycling of views, ideal for image galleries or carousels
  • Smooth animations and transitions between views
  • Customizable appearance with various attributes

Cons of InfiniteCycleViewPager

  • Limited to specific use case of cycling views
  • May require more setup for complex media playback scenarios
  • Less actively maintained compared to ExoMedia

Code Comparison

InfiniteCycleViewPager:

val infiniteCycleViewPager = findViewById<InfiniteCycleViewPager>(R.id.infiniteCycleViewPager)
infiniteCycleViewPager.adapter = MyPagerAdapter()
infiniteCycleViewPager.setScrollDuration(500)

ExoMedia:

val videoView = findViewById<VideoView>(R.id.videoView)
videoView.setVideoURI(Uri.parse("https://example.com/video.mp4"))
videoView.setOnPreparedListener { it.start() }

InfiniteCycleViewPager is focused on creating smooth, infinite cycling view pagers, making it ideal for image galleries or carousels. It offers customizable animations and transitions. However, it's limited to this specific use case and may not be suitable for complex media playback scenarios.

ExoMedia, on the other hand, is a more comprehensive media playback library built on top of ExoPlayer. It provides a wider range of features for video and audio playback, including support for various formats and streaming protocols. ExoMedia is also more actively maintained, which can be beneficial for long-term project support and bug fixes.

The code comparison shows the simplicity of setting up InfiniteCycleViewPager for cycling views, while ExoMedia's example demonstrates basic video playback setup. Each library excels in its specific domain, with InfiniteCycleViewPager being more specialized and ExoMedia offering broader media playback capabilities.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Maven Central

ExoMedia

ExoMedia is an audio/video playback library for Android built on top of the ExoPlayer with straightforward APIs and integrations. This library focuses on quick setup, handling common audio and video playback needs while also providing extensibility for more custom use cases.

ExoMedia vs ExoPlayer

The ExoPlayer is an advanced media player for Android that is highly customizable, however that comes at the cost of a more complex setup and configuration process. This customizability is great when it's needed however can be daunting when you need to play a simple audio or video file.

ExoMedia is a more high-level abstraction of media playback that abstracts some of the customizability provided by the ExoPlayer into simple functions and callbacks, keeping the required configuration to a minimum.

Use

The latest version can be found at Maven Central.

repositories {
  mavenCentral()
}

dependencies {
  implementation 'com.devbrackets.android:exomedia:5.1.0'
}

Quick Start

The ExoMedia VideoView can be added in your layout files like any other Android view.

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

	<com.devbrackets.android.exomedia.ui.widget.VideoView
		android:id="@+id/video_view"
		android:layout_width="match_parent"
		android:layout_height="match_parent" />
</RelativeLayout>

While in your Activity or Fragment you treat it like a standard Android VideoView

private lateinit var videoView: VideoView

private fun setupVideoView() {
  // Make sure to use the correct VideoView import
  videoView = findViewById(R.id.video_view) as VideoView
  videoView.setOnPreparedListener(this)

  // For now we just picked an arbitrary item to play
  videoView.setMedia(Uri.parse("https://www.devbrackets.com/media/samples/video/big_buck_bunny.mp4"))
}

@Override
fun onPrepared() {
  //Starts the video playback as soon as it is ready
  videoView.start()
}

License

Copyright 2015-2023 ExoMedia Contributors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Attribution