Android Media Framework Extras

Android Media Framework Extras

N17R

Audio Focus

This is how the Android framework knows about different applications using audio. If you want your app to fade out when other important notifications (such as navigation) occur, you'll need to learn how your app can "hop in line" to be the one in charge of audio playback, until another app requests focus.

Noisy Intent

There are certain conditions that you will want to check for. For example, imagine you are blasting your favorite song at full volume. Little does anyone know, but your favorite song is "Itsy Bitsy Spider". Right when it's about to get to the best part, you trip and yank out the headphones from the audio port. Suddenly the whole world knows your secret. Not the best experience right? Luckily the android framework sends out the ACTION_AUDIO_BECOMING_NOISY intent when this occurs. This allows you to register a broadcast receiver and take a specific action when this occurs (like pausing the music and saving yourself of embarrassment).

Audio Stream

Android uses separate audio streams for playing music, alarms, notifications, the incoming call ringer, system sounds, in-call volume, and DTMF tones. This allows users to control the volume of each stream independently.

By default, pressing the volume control modifies the volume of the active audio stream. If your app isn't currently playing anything, hitting the volume keys adjusts the ringer volume. To ensure that volume controls adjust the correct stream, you should call setVolumeControlStream() passing in AudioManager.STREAM_MUSIC.


ExoPlayer Extras

Subtitle Side Loading

Given a video file and a separate subtitle file, MergingMediaSource can be used to merge them into a single source for playback.

MediaSource videoSource = new ExtractorMediaSource(videoUri, ...);
MediaSource subtitleSource = new SingleSampleMediaSource(subtitleUri, ...);
// Plays the video with the sideloaded subtitle.
MergingMediaSource mergedSource =
new MergingMediaSource(videoSource, subtitleSource);

Looping a video

A video can be seamlessly looped using a LoopingMediaSource. The following example loops a video indefinitely. It’s also possible to specify a finite loop count when creating a LoopingMediaSource.

MediaSource source = new ExtractorMediaSource(videoUri, ...);
// Loops the video indefinitely.
LoopingMediaSource loopingSource = new LoopingMediaSource(source);


 


Similar articles

 

Android Monitor — приложение для слежки за Android устройством.
Приложение Android Monitor здорово помогает, если у вас украли смартфон. При помощи него можно подключиться к камере смартфона и посмотреть на лицо воришки, посмотреть историю звонков и местонахождение устройствах. Скачать
Android на Docker. Что?
Есть два варианта - запустить с помощью гипервизора (VirtualBox, или более быстрый Qemu) или поднять готовое решение на Docker. Что, не знаешь что такое Docker?
Android нашпигован всевозможными «маячками»
Интересное исследование представили специалисты Yale Privacy Lab (специальной лаборатории Йельского университета) и французской некоммерческой организации Exodus Privacy. Эксперты изучили более 300 популярных приложений для Android и пришли к выводу, что 75% из них содержат различные трекеры, то есть «маячки» позволяющие следить за пользователями, зачастую даже без ведома последних. Данное исследование интересно резонирует с опубликованным на прошлой неделе докладомспециалистов Принстонского университета. Напомню…
Android’ni oldingi versiyasiga qaytaramiz
Smartfonlar operatsion tizimlarining yangilanib borishi yaxshi, albatta, biroq ba’zan eng yakuniy relizlarida ham mayda kamchiliklar yoki muayyan bir qurilmaga tushmay qolishi holatlari uchrab turadi. Shuningdek, ba’zida yangi proshivka smartfon yoki planshet resurslarini ko‘proq talab qiladi, natijada gadjet qotib ishlay boshlaydi. Bunaqa holatlarda vaziyatni o‘nglashning eng maqbul yo‘li – tizimdagi yangilanishlarni bekor qilish va proshivkani oldingi versiyasiga qaytarishdir. Diqqat: o‘z Android-qurilmangiz…
Telegram notifications don't work properly (detailed troubleshooting)
​Android devices sometimes have task manager services that interfere with the Telegram notification service. For our notifications to work, you need to add Telegram to allowed apps in those devices' settings.​ The detailed steps vary a lot depending on your device, here are a few examples: Samsung Sony Xiaomi Redmi Huawei Lenovo Asus Vivo Oppo Motorola OnePlus Samsung If you have the Smart Manager app installed, please open it > Battery > App optimisation > Detail > find Telegram there and click on it > choose…

Tags

android media, framework extras

Telergaph Archive

 

Go Back