### Android Camera \& Media samples

A selection of code samples for you to use to accelerate your app development. Browse samples to learn how to build different components for your apps.

*** ** * ** ***

## Media code samples

[waving_hand](https://github.com/android/socialite)  

### [SociaLite](https://github.com/android/socialite)

This sample shows how to use various Android platform APIs and Jetpack libraries to implement features that are commonly seen in social network apps.  
[library_music](https://github.com/android/platform-samples)  

### [Platform samples](https://github.com/android/platform-samples)

This repository contains a collection of samples that demonstrate the use of different Android OS platform APIs, including camera and media APIs.  
[![](http://android.devsite.corp.google.com/static/images/media/samples/media3-transformer.svg)](https://github.com/androidx/media/tree/release/demos/transformer)  

### [Media3 Transformer](https://github.com/androidx/media/tree/release/demos/transformer)

This sample shows how to use the Media3 Transformer APIs to create a media editing app.

## Camera code samples

[![](http://android.devsite.corp.google.com/static/images/social-and-messaging/samples/camerax-basic.png)](https://github.com/android/camera-samples/tree/main/CameraXBasic)  

### [CameraX Basic](https://github.com/android/camera-samples/tree/main/CameraXBasic)

How to use CameraX APIs written in Kotlin.  
[![](http://android.devsite.corp.google.com/static/images/social-and-messaging/samples/camerax-video.png)](https://github.com/android/camera-samples/tree/main/CameraXVideo)  

### [CameraX Video](https://github.com/android/camera-samples/tree/main/CameraXVideo)

How to use the CameraX Video Capture (Recorder) API with Capture + Preview for the MediaStore format.  
[![](http://android.devsite.corp.google.com/static/images/social-and-messaging/samples/camerax-advanced.png)](https://github.com/android/camera-samples/tree/main/CameraXAdvanced)  

### [CameraX Advanced](https://github.com/android/camera-samples/tree/main/CameraXAdvanced)

How to perform real-time object detection on the live camera frames with TensorFlow Lite.  
[![](http://android.devsite.corp.google.com/static/images/social-and-messaging/samples/camerax-mlkit.png)](https://github.com/android/camera-samples/tree/main/CameraX-MLKit)  

### [CameraX-MLKit](https://github.com/android/camera-samples/tree/main/CameraX-MLKit)

How to use CameraX's MlKitAnalyzer to perform QR Code scanning. For QR Codes that encode URLs, this app prompts the user to open the URL in a browser.  
[![](http://android.devsite.corp.google.com/static/images/social-and-messaging/samples/camerax-extensions.png)](https://github.com/android/camera-samples/tree/main/CameraXExtensions)  

### [CameraX Extensions](https://github.com/android/camera-samples/tree/main/CameraXExtensions)

How to use Camera Extensions with CameraX API to capture a JPEG, display the camera preview, query for supported extensions, select an extension, and capture a still image. Available extensions include Auto, Bokeh, Face Retouch, HDR (High Dynamic Range), and Night.  
[![](http://android.devsite.corp.google.com/static/images/social-and-messaging/samples/hdr-viewfinder.png)](https://github.com/android/camera-samples/tree/main/HdrViewfinder)  

### [HDR Viewfinder (Camera2)](https://github.com/android/camera-samples/tree/main/HdrViewfinder)

How to implement a real-time high-dynamic-range camera viewfinder, by alternating the sensor's exposure time between two exposure values on even and odd frames, and then compositing together the latest two frames whenever a new frame is captured

## Test \& validation

[![](http://android.devsite.corp.google.com/static/images/media/samples/media-controller-test-app.svg)](https://github.com/googlesamples/android-media-controller)  

### [Media Controller Test app](https://github.com/googlesamples/android-media-controller)

A sample implementation of the MediaController API that you can use to test the intricacies of media playback on Android and to verify your media session implementation.

## API Demos

[![](http://android.devsite.corp.google.com/static/images/media/samples/media3-main-demo.svg)](https://github.com/androidx/media/tree/release/demos/main)  

### [Media3 Main Demo](https://github.com/androidx/media/tree/release/demos/main)

A simple playback app that uses ExoPlayer to play a number of test streams. A good starting point or reference project.  
[![](http://android.devsite.corp.google.com/static/images/media/samples/media3-session-demo.svg)](https://github.com/androidx/media/tree/release/demos/)  

### [Media3 Session Demo](https://github.com/androidx/media/tree/release/demos/)

A playback app that implements a MediaSession.  
[![](http://android.devsite.corp.google.com/static/images/media/samples/media3-cast-demo.svg)](https://github.com/androidx/media/tree/release/demos/cast)  

### [Media3 Cast Demo](https://github.com/androidx/media/tree/release/demos/cast)

A playback app with Google Cast integration. Demonstrates switching between Cast playback and local playback.  
[![](http://android.devsite.corp.google.com/static/images/media/samples/media3-surface-control-demo.svg)](https://github.com/androidx/media/tree/release/demos/surface)  

### [Media3 SurfaceControl Demo](https://github.com/androidx/media/tree/release/demos/surface)

A playback app that uses the SurfaceControl API to redirect ExoPlayer's video output to different views. Requires minSdkVersion 29.  
[![](http://android.devsite.corp.google.com/static/images/media/samples/media3-gl-demo.svg)](https://github.com/androidx/media/tree/release/demos/gl)  

### [Media3 GL Demo](https://github.com/androidx/media/tree/release/demos/gl)

A playback app that renders video to a GLSurfaceView and applies a GL shader.  
[![](http://android.devsite.corp.google.com/static/images/media/samples/midi-samples.svg)](https://github.com/android/midi-samples)  

### [MIDI Samples](https://github.com/android/midi-samples)

This collection of sample apps showcases MIDI 2.0 APIs introduced in Android 13.