跳到主要内容

Audio-Only Player

This guide shows how to set up a player with audio-only assets via the BlendVision Android Player SDK. You can also check the sample project for audio-only assets player.

For the basic player SDK integration, you may refer to Getting Started.

Obvious difference from video playback

Background Image

When playing an audio stream, by default, the background is black. You can customize the background image with setPoster(url) method, like the following snippet:

//set poster between player and control panel
player.setPoster("YOUR_IMAGE_URL")

//If you want to remove the poster, you can do that by using
player.setPoster(null)

Quality Setting

The quality setting applies for video streams with multiple bitrate variants and isn’t available for audio-only streams.

Custom UI and Setup

Set player layout

<com.blendvision.player.playback.presentation.UniView
android:id="@+id/blendVisionPlayer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

Initialize player

private fun initializePlayer() {
val playerConfig = PlayerConfig(isLoopEnabled = true, playLogger = object : PlayLogger {
override fun logEvent(eventName: String, properties: Map<String, Any>) {
// log event callback
}
})
val player = UniPlayer.Builder(context = context, playerConfig = playerConfig).build()

binding.blendVisionPlayer.setupControlPanel(autoKeepScreenOnEnabled = true, defaultPanelType = PanelType.EMBEDDED)
binding.blendVisionPlayer.setUnifiedPlayer(player)
}

Customize background image

fun setPlayerBackground(imageUrl: String?) {
player.setPoster("YOUR_IMAGE_URL")
}

Load and control media

// Media Configuration
val mediaConfig = MediaConfig(
source = MediaConfig.Source(
url = "YOUR_DASH_URL",
protocol = MediaConfig.Protocol.DASH
),
title = "TITLE",
imageUrl = "YOUR_IMAGE_URL",
thumbnailSeekingUrl = null,
playWhenReady = true,
sharedUrl = "SHARED_INFO",
description = "YOUR_DESCRIPTION_INFO"
)

// Load and Control Media
player.load(mediaConfig)
player.start()
player.pause()
player.play()
player.stop()
player.release()
Limitation
  • Audio playback might not be available on Chromecast.