Convert Figma logo to code with AI

android logouamp

A sample audio app for Android

13,082
3,750
13,082
93

Top Related Projects

21,714

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

21,774

The Google I/O Android App

13,084

A sample audio app for Android

32,488

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

Quick Overview

UAMP (Universal Android Music Player) is a sample music player app that showcases best practices for media playback on Android. It demonstrates how to implement a media player that works across different form factors and provides a consistent user experience on mobile devices, Android Auto, Android Wear, and Android TV.

Pros

  • Demonstrates best practices for media playback on Android
  • Supports multiple Android platforms (mobile, Auto, Wear, TV)
  • Implements modern Android architecture components
  • Serves as a comprehensive reference for developers building media apps

Cons

  • May be overwhelming for beginners due to its comprehensive nature
  • Requires understanding of multiple Android components and APIs
  • Not intended for direct use in production apps without modifications
  • May not cover all edge cases or specific requirements for every media app

Code Examples

  1. Initializing the MediaBrowserServiceCompat:
class MusicService : MediaBrowserServiceCompat() {
    override fun onCreate() {
        super.onCreate()
        // Initialize media session, player, and other components
    }

    override fun onGetRoot(clientPackageName: String, clientUid: Int, rootHints: Bundle?): BrowserRoot? {
        // Return the root media ID for browsing
    }

    override fun onLoadChildren(parentId: String, result: Result<MutableList<MediaBrowserCompat.MediaItem>>) {
        // Load and return child media items
    }
}
  1. Implementing a MediaBrowserCompat client:
private lateinit var mediaBrowser: MediaBrowserCompat

private fun connectToMediaBrowser() {
    mediaBrowser = MediaBrowserCompat(
        this,
        ComponentName(this, MusicService::class.java),
        object : MediaBrowserCompat.ConnectionCallback() {
            override fun onConnected() {
                // Media browser connected, perform actions
            }
        },
        null
    )
    mediaBrowser.connect()
}
  1. Handling media playback controls:
private lateinit var mediaController: MediaControllerCompat

private fun setupMediaController() {
    mediaController = MediaControllerCompat(this, mediaBrowser.sessionToken)
    mediaController.registerCallback(object : MediaControllerCompat.Callback() {
        override fun onPlaybackStateChanged(state: PlaybackStateCompat?) {
            // Update UI based on playback state
        }

        override fun onMetadataChanged(metadata: MediaMetadataCompat?) {
            // Update UI with new metadata
        }
    })
}

Getting Started

To get started with UAMP:

  1. Clone the repository:

    git clone https://github.com/android/uamp.git
    
  2. Open the project in Android Studio.

  3. Build and run the app on your desired Android device or emulator.

  4. Explore the code and documentation to understand the implementation details and best practices demonstrated in the project.

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

  • More comprehensive and feature-rich media player library
  • Supports a wider range of audio and video formats
  • Better performance and efficiency for complex media playback scenarios

Cons of ExoPlayer

  • Steeper learning curve due to its complexity
  • Larger library size, which may increase app size
  • Potentially overkill for simple audio playback needs

Code Comparison

ExoPlayer initialization:

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

UAMP initialization:

val mediaSession = MediaSessionCompat(context, "MySession")
val player = MediaPlayer()
player.setDataSource(context, mediaUri)
player.prepare()
player.start()

ExoPlayer offers more advanced features and flexibility, while UAMP provides a simpler implementation for basic audio playback. ExoPlayer is better suited for complex media applications, whereas UAMP is more appropriate for straightforward audio use cases. The code comparison shows that ExoPlayer requires more setup but offers greater control over playback, while UAMP has a simpler initialization process for basic audio playback scenarios.

21,774

The Google I/O Android App

Pros of iosched

  • More comprehensive showcase of Android development best practices
  • Larger codebase with more complex features and UI components
  • Includes conference-specific features like scheduling and navigation

Cons of iosched

  • Potentially overwhelming for beginners due to its complexity
  • Less focused on audio playback functionality
  • May require more setup and configuration to run

Code Comparison

iosched (Kotlin):

@Composable
fun SessionItem(
    session: Session,
    modifier: Modifier = Modifier,
    showTime: Boolean = true,
    showDay: Boolean = false
) {
    // Session item implementation
}

uamp (Kotlin):

@Composable
fun MediaItemList(
    list: List<MediaItemData>,
    onMediaItemClick: (MediaItemData) -> Unit,
    modifier: Modifier = Modifier
) {
    // Media item list implementation
}

Both projects use Jetpack Compose for UI, but iosched focuses on conference-related components while uamp emphasizes media playback interfaces. iosched's codebase is more extensive, covering a wider range of Android development aspects, while uamp is more specialized for audio playback scenarios.

13,084

A sample audio app for Android

Pros of uamp

  • Demonstrates best practices for media playback in Android
  • Showcases integration with Android Auto, Wear OS, and Google Assistant
  • Provides a comprehensive example of using ExoPlayer and MediaSession

Cons of uamp

  • May be overly complex for simple media playback needs
  • Requires understanding of multiple Android components and libraries
  • Could be challenging for beginners to navigate and understand

Code Comparison

Both repositories contain the same codebase, as they are the same project. Here's a sample from the MainActivity.kt file:

class MainActivity : AppCompatActivity() {
    private lateinit var binding: ActivityMainBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(binding.root)
    }
}

Summary

The uamp (Universal Android Music Player) repository serves as a reference implementation for building media playback applications on Android. It demonstrates how to integrate various Android components and libraries to create a full-featured music player. While it provides extensive examples and best practices, its complexity may be overwhelming for simpler projects or beginners. The repository is valuable for developers looking to implement advanced media playback features or integrate with Android ecosystem components like Android Auto and Wear OS.

32,488

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

Pros of ijkplayer

  • More comprehensive media player solution with support for various formats and protocols
  • Better performance for video playback, especially for streaming content
  • Larger community and more frequent updates

Cons of ijkplayer

  • More complex to integrate and use compared to UAMP
  • Larger library size, which may increase app size
  • Requires more configuration and customization for specific use cases

Code Comparison

UAMP (Kotlin):

class MusicService : MediaBrowserServiceCompat() {
    private lateinit var mediaSession: MediaSessionCompat
    private lateinit var mediaController: MediaControllerCompat
    // ...
}

ijkplayer (Java):

public class IJKVideoView extends FrameLayout {
    private IMediaPlayer mMediaPlayer;
    private IRenderView mRenderView;
    // ...
}

Summary

UAMP is a simpler, more focused audio player sample for Android, while ijkplayer is a more comprehensive media player solution with broader format support and better video playback performance. UAMP is easier to integrate but has limited features, while ijkplayer offers more flexibility at the cost of increased complexity. The choice between the two depends on the specific requirements of your project, such as the types of media you need to support and the level of customization required.

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

Universal Android Music Player Sample

The goal of this sample is to show how to implement an audio media app that works across multiple form factors and provides a consistent user experience on Android phones, tablets, Android Auto, Android Wear, Android TV, Google Cast devices, and with the Google Assistant.

To get started with UAMP please read the full guide.

Screenshot showing UAMP's UI for browsing albums and songs Screenshot showing UAMP's UI for playing a song

Pre-requisites

  • Android Studio 3.x

Getting Started

This sample uses the Gradle build system. To build this project, use the "gradlew build" command or use "Import Project" in Android Studio.

Support

If you've found an error in this sample, please file an issue

Patches are encouraged and may be submitted by forking this project and submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details.

Audio

Music provided by the Free Music Archive.

Recordings provided by the Ambisonic Sound Library.

License

Copyright 2017 Google Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you 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.