Skip to content

Unofficial YouTube Music / Spotify Premium client for Android, built in Liquid Glass. Audio effects, Spotify Connect, listening history, 8 languages. Rust core on librespot.

Work in progress: play Spotify the web player's way for refused accounts

Lelonioa01cd03f5353
diff --git a/app/src/main/java/dev/lelonio/square/SquareApplication.kt b/app/src/main/java/dev/lelonio/square/SquareApplication.kt
index 9a2423e..56f8fde 100644
--- a/app/src/main/java/dev/lelonio/square/SquareApplication.kt
+++ b/app/src/main/java/dev/lelonio/square/SquareApplication.kt
@@ -34,6 +34,8 @@ class SquareApplication : Application(), ImageLoaderFactory {
super.onCreate()
// First, so a crash anywhere below is written down; see Report.
dev.lelonio.square.diagnostics.Report.install(this)
+ // Temporary, dev builds only; see WidevineProbe.
+ dev.lelonio.square.diagnostics.WidevineProbe.register(this)
// The vendored InnerTube module logs through Timber, and with nothing
// planted every one of those lines went nowhere — which is why a
// YouTube page that came back in an unexpected shape could only be
diff --git a/app/src/main/java/dev/lelonio/square/backend/spotify/SpotifyWebPlayback.kt b/app/src/main/java/dev/lelonio/square/backend/spotify/SpotifyWebPlayback.kt
new file mode 100644
index 0000000..3975836
--- /dev/null
+++ b/app/src/main/java/dev/lelonio/square/backend/spotify/SpotifyWebPlayback.kt
@@ -0,0 +1,325 @@
+package dev.lelonio.square.backend.spotify
+
+import android.content.Context
+import android.os.Looper
+import androidx.media3.common.AudioAttributes
+import androidx.media3.common.C
+import androidx.media3.common.ForwardingPlayer
+import androidx.media3.common.MediaItem
+import androidx.media3.common.Player
+import androidx.media3.common.util.UnstableApi
+import androidx.media3.datasource.DataSpec
+import androidx.media3.datasource.DefaultDataSource
+import androidx.media3.datasource.DefaultHttpDataSource
+import androidx.media3.datasource.ResolvingDataSource
+import androidx.media3.exoplayer.ExoPlayer
+import androidx.media3.exoplayer.RenderersFactory
+import androidx.media3.exoplayer.drm.DefaultDrmSessionManager
+import androidx.media3.exoplayer.drm.ExoMediaDrm
+import androidx.media3.exoplayer.drm.FrameworkMediaDrm
+import androidx.media3.exoplayer.drm.HttpMediaDrmCallback
+import androidx.media3.exoplayer.drm.MediaDrmCallback
+import androidx.media3.exoplayer.source.DefaultMediaSourceFactory
+import dev.lelonio.square.nativecore.NativeBridge
+import kotlinx.coroutines.flow.MutableSharedFlow
+import kotlinx.coroutines.flow.SharedFlow
+import kotlinx.coroutines.flow.asSharedFlow
+import okhttp3.OkHttpClient
+import okhttp3.Request
+import org.json.JSONObject
+import java.util.UUID
+import java.util.concurrent.ConcurrentHashMap
+
+/**
+ * Spotify played the way its web player plays it, for the accounts whose
+ * audio keys Spotify refuses (#35).
+ *
+ * The engine asks for each song's key over a channel Spotify closes to some
+ * accounts, and then there is nothing to decrypt the song with. The web player
+ * never uses that channel: it plays the MP4 version of the song, protected with
+ * Widevine, with a licence from spclient. Android has Widevine, the licence is
+ * granted to the token the engine already holds, and ExoPlayer plays the file.
+ *
+ * Two things learnt on a real phone shape this:
+ * - Widevine at L3, the software level browsers use. At L1 the decoder was
+ * handed undecryptable data after every seek, and played silence.
+ * - A song starts from its beginning and is then moved to where it should be:
+ * started straight at a position, it decoded to silence even at L3. See
+ * [StartThenSeek].
+ *
+ * What this cannot do: Spotify Connect (the phone is not a Connect device
+ * while this plays), the engine's downloads, and 320 kbps (the web player's
+ * best is 256).
+ */
+@UnstableApi
+object SpotifyWebPlayback {
+
+ private const val SPCLIENT = "https://spclient.wg.spotify.com"
+ private const val LICENCE = "$SPCLIENT/widevine-license/v1/audio/license"
+ private const val TAG = "SquareWebPlayback"
+ private const val TRACK_PREFIX = "spotify:track:"
+
+ private val http = OkHttpClient()
+
+ private val _accountRefused = MutableSharedFlow<Unit>(extraBufferCapacity = 1)
+
+ /** Said by the engine's player when Spotify refuses this account every key. */
+ val accountRefused: SharedFlow<Unit> = _accountRefused.asSharedFlow()
+
+ fun reportAccountRefused() {
+ _accountRefused.tryEmit(Unit)
+ }
+
+ /** Whether Spotify has refused this account its keys; remembered by LibrespotPlayer. */
+ fun needed(context: Context): Boolean =
+ context.getSharedPreferences("square_keys", Context.MODE_PRIVATE)
+ .getBoolean("account_refused", false)
+
+ fun create(context: Context, looper: Looper, renderers: RenderersFactory): Player {
+ val drm = DefaultDrmSessionManager.Builder()
+ .setUuidAndExoMediaDrmProvider(C.WIDEVINE_UUID) { uuid: UUID ->
+ FrameworkMediaDrm.newInstance(uuid).apply {
+ // setPropertyString("securityLevel", "L3")
+ android.util.Log.i(TAG, "widevine level now ${getPropertyString("securityLevel")}")
+ }
+ }
+ // One session per song, so the next can be readied while this plays.
+ .setMultiSession(false)
+ .build(Licence())
+ val sources = DefaultMediaSourceFactory(
+ ResolvingDataSource.Factory(
+ DefaultDataSource.Factory(context, DefaultHttpDataSource.Factory()),
+ Resolver(),
+ ),
+ ).setDrmSessionManagerProvider { drm }
+ // Temporary: the decoded signal's peak, every second, to see when it goes to zero.
+ val meter = object : androidx.media3.exoplayer.audio.TeeAudioProcessor.AudioBufferSink {
+ @Volatile var peak = 0
+ override fun flush(sampleRateHz: Int, channelCount: Int, encoding: Int) {
+ android.util.Log.i(TAG, "pcm $sampleRateHz Hz $channelCount ch enc $encoding")
+ }
+ override fun handleBuffer(buffer: java.nio.ByteBuffer) {
+ val shorts = buffer.duplicate().order(java.nio.ByteOrder.nativeOrder()).asShortBuffer()
+ var p = peak
+ while (shorts.hasRemaining()) { val v = kotlin.math.abs(shorts.get().toInt()); if (v > p) p = v }
+ peak = p
+ }
+ }
+ val metered = object : androidx.media3.exoplayer.DefaultRenderersFactory(context) {
+ override fun buildAudioSink(c: Context, f: Boolean, p: Boolean) =
+ androidx.media3.exoplayer.audio.DefaultAudioSink.Builder(c)
+ .setAudioProcessors(arrayOf(androidx.media3.exoplayer.audio.TeeAudioProcessor(meter)))
+ .build()
+ }
+ val exo = ExoPlayer.Builder(context, metered)
+ .setLooper(looper)
+ .setMediaSourceFactory(sources)
+ .setHandleAudioBecomingNoisy(true)
+ .setAudioAttributes(
+ AudioAttributes.Builder()
+ .setUsage(C.USAGE_MEDIA)
+ .setContentType(C.AUDIO_CONTENT_TYPE_MUSIC)
+ .build(),
+ /* handleAudioFocus = */ true,
+ )
+ .build()
+ // Temporary: what the DRM and the decoder do, while this is being made to work.
+ exo.addAnalyticsListener(object : androidx.media3.exoplayer.analytics.AnalyticsListener {
+ override fun onDrmKeysLoaded(eventTime: androidx.media3.exoplayer.analytics.AnalyticsListener.EventTime) {
+ android.util.Log.i(TAG, "keys loaded")
+ }
+ override fun onDrmSessionAcquired(eventTime: androidx.media3.exoplayer.analytics.AnalyticsListener.EventTime, state: Int) {
+ android.util.Log.i(TAG, "drm session acquired, state $state")
+ }
+ override fun onDrmSessionManagerError(eventTime: androidx.media3.exoplayer.analytics.AnalyticsListener.EventTime, error: Exception) {
+ android.util.Log.w(TAG, "drm error", error)
+ }
+ override fun onAudioCodecError(eventTime: androidx.media3.exoplayer.analytics.AnalyticsListener.EventTime, audioCodecError: Exception) {
+ android.util.Log.w(TAG, "codec error", audioCodecError)
+ }
+ override fun onAudioDecoderInitialized(eventTime: androidx.media3.exoplayer.analytics.AnalyticsListener.EventTime, decoderName: String, initializedTimestampMs: Long, initializationDurationMs: Long) {
+ android.util.Log.i(TAG, "decoder $decoderName")
+ }
+ override fun onPlayerError(eventTime: androidx.media3.exoplayer.analytics.AnalyticsListener.EventTime, error: androidx.media3.common.PlaybackException) {
+ android.util.Log.w(TAG, "player error ${error.errorCodeName}", error)
+ }
+ })
+ val tick = android.os.Handler(looper)
+ tick.post(object : Runnable {
+ override fun run() {
+ if (exo.isPlaying) android.util.Log.i(TAG, "t pos=${exo.currentPosition} peak=${meter.peak}")
+ meter.peak = 0
+ tick.postDelayed(this, 1_000)
+ }
+ })
+ exo.volume = 0f
+ return StartThenSeek(exo)
+ }
+
+ /** The licence, asked with whatever token the engine holds at that moment. */
+ private class Licence : MediaDrmCallback {
+ private val http = DefaultHttpDataSource.Factory()
+
+ override fun executeProvisionRequest(uuid: UUID, request: ExoMediaDrm.ProvisionRequest): MediaDrmCallback.Response =
+ HttpMediaDrmCallback(null, http).executeProvisionRequest(uuid, request)
+
+ override fun executeKeyRequest(uuid: UUID, request: ExoMediaDrm.KeyRequest): MediaDrmCallback.Response {
+ val callback = HttpMediaDrmCallback(LICENCE, http)
+ NativeBridge.accessToken()?.let { callback.setKeyRequestProperty("Authorization", "Bearer $it") }
+ android.util.Log.i(TAG, "licence request type=${request.requestType} url=${request.licenseServerUrl.ifEmpty { "(default)" }} ${request.data.size} bytes")
+ return runCatching { callback.executeKeyRequest(uuid, request) }
+ .onSuccess { android.util.Log.i(TAG, "licence answer ${it.data.size} bytes") }
+ .onFailure { android.util.Log.w(TAG, "licence failed: $it") }
+ .getOrThrow()
+ }
+ }
+
+ /**
+ * Turns `spotify:track:` into the address of its MP4 file, at load time:
+ * the address is signed and expires, so the queue keeps the song's name.
+ * Runs on ExoPlayer's loading thread, so blocking is correct.
+ */
+ private class Resolver : ResolvingDataSource.Resolver {
+ private val resolved = ConcurrentHashMap<String, Pair<Long, String>>()
+
+ override fun resolveDataSpec(dataSpec: DataSpec): DataSpec {
+ val uri = dataSpec.uri.toString()
+ if (!uri.startsWith(TRACK_PREFIX)) return dataSpec
+ val id = uri.removePrefix(TRACK_PREFIX)
+ val now = android.os.SystemClock.elapsedRealtime()
+ val cdn = resolved[id]?.takeIf { now - it.first < CDN_TTL_MS }?.second
+ ?: cdnFor(id).also { resolved[id] = now to it }
+ return dataSpec.withUri(android.net.Uri.parse(cdn))
+ }
+
+ private fun cdnFor(id: String): String {
+ val token = NativeBridge.accessToken() ?: error("the engine has no token")
+ // The web player's own manifest is where the MP4 files are listed;
+ // the track metadata no longer names files at all.
+ val media = get(
+ "$SPCLIENT/track-playback/v1/media/$TRACK_PREFIX$id" +
+ "?manifestFileFormat=file_ids_mp4&manifestFileFormat=file_ids_mp4_dual",
+ token,
+ )
+ val files = JSONObject(media).optJSONObject("media")?.optJSONObject("$TRACK_PREFIX$id")
+ ?.optJSONObject("item")?.optJSONObject("manifest")
+ ?.let { it.optJSONArray("file_ids_mp4") ?: it.optJSONArray("file_ids_mp4_dual") }
+ ?: error("no MP4 file for $id")
+ val all = (0 until files.length()).map { files.getJSONObject(it) }
+ // The best the web player has: 256 kbps, then 128.
+ val file = all.maxByOrNull { it.optInt("bitrate") } ?: error("no MP4 file for $id")
+ val fileId = file.getString("file_id")
+ val resolve = get(
+ "$SPCLIENT/storage-resolve/v2/files/audio/interactive/11/$fileId" +
+ "?version=10000000&product=9&platform=39&alt=json",
+ token,
+ )
+ return JSONObject(resolve).optJSONArray("cdnurl")?.optString(0)
+ ?.takeIf { it.isNotEmpty() } ?: error("no address for $id")
+ }
+
+ private fun get(url: String, token: String): String {
+ val request = Request.Builder().url(url)
+ .header("Authorization", "Bearer $token")
+ .header("Accept", "application/json")
+ .build()
+ return http.newCall(request).execute().use { response ->
+ if (!response.isSuccessful) error("HTTP ${response.code} for $url")
+ response.body?.string() ?: error("empty answer for $url")
+ }
+ }
+ }
+
+ /**
+ * Starts every song at its beginning and moves it where it was asked to be
+ * once it is playing. Started straight at a position, the decoder produced
+ * silence; moved after its first frames, it plays. The song is kept silent
+ * for that moment, so the beginning is not heard on the way past.
+ */
+ private class StartThenSeek(private val exo: ExoPlayer) : ForwardingPlayer(exo) {
+
+ /** Where the song should be once it has started; unset when nothing is waiting. */
+ private var pending = C.TIME_UNSET
+
+ /** The item that has been heard playing, by its uid in the timeline; null for none yet. */
+ private var startedUid: Any? = null
+
+ private val handler = android.os.Handler(exo.applicationLooper)
+
+ /** Puts the sound back whatever happened to the seek it was lowered for. */
+ private val unmute = Runnable {
+ android.util.Log.i(TAG, "unmute skipped while measuring")
+ }
+
+ init {
+ exo.addListener(object : Player.Listener {
+ override fun onMediaItemTransition(mediaItem: MediaItem?, reason: Int) {
+ android.util.Log.i(TAG, "item ${mediaItem?.mediaId} (reason $reason)")
+ }
+
+ override fun onIsPlayingChanged(isPlaying: Boolean) {
+ if (!isPlaying) return
+ startedUid = currentUid()
+ flush()
+ }
+ })
+ }
+
+ private fun currentUid(): Any? =
+ if (exo.currentTimeline.isEmpty) null
+ else exo.currentTimeline.getPeriod(exo.currentPeriodIndex, androidx.media3.common.Timeline.Period(), true).uid
+
+ private fun hasStarted() = startedUid != null && startedUid == currentUid()
+
+ /** The waiting seek, now that the song is playing: a moment after, while silent. */
+ private fun flush() {
+ val target = pending
+ if (target == C.TIME_UNSET) return
+ pending = C.TIME_UNSET
+ handler.postDelayed({
+ android.util.Log.i(TAG, "seek after start to $target")
+ exo.seekTo(target)
+ handler.removeCallbacks(unmute)
+ handler.postDelayed(unmute, UNMUTE_AFTER_SEEK_MS)
+ }, SEEK_AFTER_START_MS)
+ }
+
+ private fun later(positionMs: Long) {
+ if (positionMs <= 0) {
+ pending = C.TIME_UNSET
+ return
+ }
+ pending = positionMs
+ exo.volume = 0f
+ // Never left silent: whatever becomes of the seek, the sound comes back.
+ handler.removeCallbacks(unmute)
+ handler.postDelayed(unmute, MAX_SILENCE_MS)
+ if (exo.isPlaying) flush()
+ }
+
+ override fun setMediaItems(mediaItems: MutableList<MediaItem>, startIndex: Int, startPositionMs: Long) {
+ startedUid = null
+ android.util.Log.i(TAG, "queue of ${mediaItems.size} at $startIndex, $startPositionMs ms")
+ super.setMediaItems(mediaItems, startIndex, 0)
+ later(startPositionMs)
+ }
+
+ override fun seekTo(mediaItemIndex: Int, positionMs: Long) {
+ val sameItem = mediaItemIndex == currentMediaItemIndex
+ android.util.Log.i(TAG, "seek to $mediaItemIndex/$positionMs (same=$sameItem started=${hasStarted()})")
+ if (sameItem && hasStarted()) {
+ super.seekTo(mediaItemIndex, positionMs)
+ } else {
+ super.seekTo(mediaItemIndex, 0)
+ later(positionMs)
+ }
+ }
+
+ override fun seekTo(positionMs: Long) = seekTo(currentMediaItemIndex, positionMs)
+ }
+
+ private const val CDN_TTL_MS = 30 * 60 * 1000L
+ private const val SEEK_AFTER_START_MS = 400L
+ private const val UNMUTE_AFTER_SEEK_MS = 250L
+ private const val MAX_SILENCE_MS = 2_000L
+}
diff --git a/app/src/main/java/dev/lelonio/square/diagnostics/WidevineProbe.kt b/app/src/main/java/dev/lelonio/square/diagnostics/WidevineProbe.kt
new file mode 100644
index 0000000..a2751a1
--- /dev/null
+++ b/app/src/main/java/dev/lelonio/square/diagnostics/WidevineProbe.kt
@@ -0,0 +1,390 @@
+package dev.lelonio.square.diagnostics
+
+import android.content.BroadcastReceiver
+import android.content.Context
+import android.content.Intent
+import android.content.IntentFilter
+import android.media.MediaDrm
+import android.util.Base64
+import androidx.core.content.ContextCompat
+import dev.lelonio.square.BuildConfig
+import dev.lelonio.square.nativecore.NativeBridge
+import okhttp3.MediaType.Companion.toMediaType
+import okhttp3.OkHttpClient
+import okhttp3.Request
+import okhttp3.RequestBody.Companion.toRequestBody
+import org.json.JSONObject
+import java.math.BigInteger
+
+/**
+ * Temporary, dev builds only: whether a Spotify track can be played the way
+ * the web player plays it — the MP4 file, Widevine, a licence from spclient —
+ * for the accounts whose audio keys are refused (#35).
+ *
+ * Started from adb, runs on the phone so the account's token never leaves it,
+ * and logs only what each step answered:
+ *
+ * adb shell am broadcast -a dev.lelonio.square.PROBE_WIDEVINE \
+ * --es track 1mblCC44D31Yu2o3DhrvbJ -p dev.lelonio.square
+ */
+object WidevineProbe {
+
+ private const val ACTION = "dev.lelonio.square.PROBE_WIDEVINE"
+ private const val TAG = "SquareProbe"
+ private const val SPCLIENT = "https://spclient.wg.spotify.com"
+ private val WIDEVINE = java.util.UUID.fromString("edef8ba9-79d6-4ace-a3c8-27dcd51d21ed")
+ private val http = OkHttpClient()
+
+ fun register(context: Context) {
+ if (!BuildConfig.VERBOSE_LOG) return
+ appContext = context.applicationContext
+ ContextCompat.registerReceiver(
+ context,
+ object : BroadcastReceiver() {
+ override fun onReceive(context: Context, intent: Intent) {
+ if (intent.getBooleanExtra("reference", false)) {
+ playReference()
+ return
+ }
+ // Pretends Spotify refuses this account its keys, or stops
+ // pretending: the way to try SpotifyWebPlayback on an account
+ // that is not refused.
+ intent.getStringExtra("web")?.let { mode ->
+ val on = mode == "on"
+ context.getSharedPreferences("square_keys", Context.MODE_PRIVATE)
+ .edit().putBoolean("account_refused", on).apply()
+ log("web playback forced ${if (on) "on" else "off"}")
+ if (on) {
+ forceWeb()
+ }
+ return
+ }
+ val track = intent.getStringExtra("track") ?: "1mblCC44D31Yu2o3DhrvbJ"
+ Thread({ runCatching { probe(track) }.onFailure { log("failed: $it") } }, "SquareProbe").start()
+ }
+ },
+ IntentFilter(ACTION),
+ ContextCompat.RECEIVER_EXPORTED,
+ )
+ }
+
+ @androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class)
+ private fun forceWeb() = dev.lelonio.square.backend.spotify.SpotifyWebPlayback.reportAccountRefused()
+
+ private fun log(message: String) { android.util.Log.i(TAG, message) }
+
+ private fun probe(track: String) {
+ val token = NativeBridge.accessToken() ?: return log("no token: is the engine signed in?")
+ val gid = gidOf(track)
+ log("track $track = gid $gid")
+
+ // 1. The files the track comes in.
+ val (metaCode, meta) = get("$SPCLIENT/metadata/4/track/$gid?market=from_token", token, json = true)
+ log("1 metadata: HTTP $metaCode")
+ meta?.let { body ->
+ val root = runCatching { JSONObject(body) }.getOrNull()
+ log("1 keys: ${root?.keys()?.asSequence()?.toList()}")
+ log("1 sample: ${body.take(600)}")
+ root?.optJSONArray("file")?.let { log("1 file[0]: ${it.optJSONObject(0)}") }
+ log("1 audio_formats: ${root?.opt("audio_formats").toString().take(700)}")
+ log("1 original_audio: ${root?.opt("original_audio").toString().take(400)}")
+ root?.optJSONArray("alternative")?.let { log("1 alternatives: ${it.length()}") }
+ }
+ val files = meta?.let { JSONObject(it) }?.let { root ->
+ val list = root.optJSONArray("file") ?: root.optJSONArray("alternative")
+ ?.optJSONObject(0)?.optJSONArray("file")
+ (0 until (list?.length() ?: 0)).map { list!!.getJSONObject(it) }
+ .map { it.optString("format") to it.optString("file_id") }
+ }.orEmpty()
+ log("1 formats in metadata: ${files.joinToString { it.first }}")
+
+ // 1b. Where the web player asks: its media manifest lists the MP4 files.
+ val (mediaCode, media) = get(
+ "$SPCLIENT/track-playback/v1/media/spotify:track:$track?manifestFileFormat=file_ids_mp4&manifestFileFormat=file_ids_mp4_dual",
+ token,
+ json = true,
+ )
+ log("1b media: HTTP $mediaCode, ${media?.take(500)}")
+ val mp4Files = media?.let { runCatching { JSONObject(it) }.getOrNull() }
+ ?.optJSONObject("media")?.optJSONObject("spotify:track:$track")
+ ?.optJSONObject("item")?.optJSONObject("manifest")
+ ?.let { manifest -> manifest.optJSONArray("file_ids_mp4") ?: manifest.optJSONArray("file_ids_mp4_dual") }
+ log("1b all MP4 files: ${(0 until (mp4Files?.length() ?: 0)).map { mp4Files!!.optJSONObject(it) }.joinToString { "format=${it.optString("format")} bitrate=${it.optString("bitrate")}" }}")
+ val first = (0 until (mp4Files?.length() ?: 0)).map { mp4Files!!.optJSONObject(it) }
+ .firstOrNull { it.optString("format") == "11" } ?: mp4Files?.optJSONObject(0)
+ ?: return log("1b no MP4 file offered by the media manifest")
+ val fileId = first.optString("file_id")
+ log("1b chose MP4 file: format=${first.optString("format")} bitrate=${first.optString("bitrate")}")
+
+ // 2. What protects it.
+ val (seekCode, seek) = get("https://seektables.scdn.co/seektable/$fileId.json", null, json = true)
+ val seektable = seek?.let { runCatching { JSONObject(it) }.getOrNull() }
+ val pssh = seektable?.optString("pssh").orEmpty()
+ log("2 seektable: HTTP $seekCode, keys=${seektable?.keys()?.asSequence()?.toList()}, pssh=${pssh.length} chars")
+
+ // 3. Where it lives.
+ val (resolveCode, resolve) = get(
+ "$SPCLIENT/storage-resolve/v2/files/audio/interactive/11/$fileId?version=10000000&product=9&platform=39&alt=json",
+ token,
+ json = true,
+ )
+ val cdn = resolve?.let { runCatching { JSONObject(it) }.getOrNull() }
+ ?.optJSONArray("cdnurl")?.optString(0)
+ log("3 storage-resolve: HTTP $resolveCode, cdn=${cdn != null}")
+
+ // 4. Whether the file carries its own protection box.
+ if (cdn != null) {
+ val head = http.newCall(Request.Builder().url(cdn).header("Range", "bytes=0-65535").build()).execute()
+ val bytes = head.body?.bytes() ?: ByteArray(0)
+ val text = String(bytes, Charsets.ISO_8859_1)
+ log(
+ "4 file head: HTTP ${head.code}, ${bytes.size} bytes, boxes: " +
+ listOf("ftyp", "moov", "pssh", "sidx", "moof", "tenc").filter { text.contains(it) },
+ )
+ fun hexAt(name: String, length: Int): String {
+ val at = text.indexOf(name)
+ if (at < 0) return "absent"
+ return bytes.copyOfRange(at + 4, minOf(bytes.size, at + 4 + length)).joinToString("") { "%02x".format(it) }
+ }
+ val schm = text.indexOf("schm")
+ log("4 schm scheme: ${if (schm >= 0) String(bytes, schm + 8, 4, Charsets.ISO_8859_1) else "absent"} raw=${hexAt("schm", 12)}")
+ log("4 tenc: ${hexAt("tenc", 32)}")
+ log("4 senc: ${hexAt("senc", 24)} saiz: ${hexAt("saiz", 12)} saio: ${hexAt("saio", 12)}")
+ log("4 stsd/enca: ${text.contains("enca")} frma: ${hexAt("frma", 4)}")
+ // A stretch well past the clear lead: what an encrypted fragment carries.
+ val later = http.newCall(Request.Builder().url(cdn).header("Range", "bytes=1000000-1400000").build()).execute()
+ val laterBytes = later.body?.bytes() ?: ByteArray(0)
+ val laterText = String(laterBytes, Charsets.ISO_8859_1)
+ val boxes = listOf("moof", "traf", "tfhd", "trun", "senc", "saiz", "saio", "sbgp", "sgpd", "uuid", "mdat")
+ .associateWith { name -> laterText.split(name).size - 1 }
+ fun box(src: ByteArray, srcText: String, name: String, max: Int = 80): String {
+ val at = srcText.indexOf(name)
+ if (at < 0) return "absent"
+ val size = java.nio.ByteBuffer.wrap(src, at - 4, 4).int
+ return "size=$size " + src.copyOfRange(at - 4, minOf(src.size, at - 4 + minOf(size, max))).joinToString("") { "%02x".format(it) }
+ }
+ log("4 head sgpd: ${box(bytes, text, "sgpd")}")
+ log("4 head sbgp: ${box(bytes, text, "sbgp")}")
+ log("4 later sbgp: ${box(laterBytes, laterText, "sbgp")}")
+ log("4 later sgpd: ${box(laterBytes, laterText, "sgpd")}")
+ log("4 later senc: ${box(laterBytes, laterText, "senc", 64)}")
+ log("4 later stretch: HTTP ${later.code}, ${laterBytes.size} bytes, box counts $boxes")
+ val moof = laterText.indexOf("moof")
+ if (moof >= 0) {
+ val size = java.nio.ByteBuffer.wrap(laterBytes, moof - 4, 4).int
+ log("4 first moof there: $size bytes: " + laterBytes.copyOfRange(moof - 4, minOf(laterBytes.size, moof - 4 + minOf(size, 200))).joinToString("") { "%02x".format(it) })
+ }
+ }
+
+ // 5. Whether Spotify gives a licence for it with the token we have.
+ if (pssh.isEmpty()) return log("5 skipped: no pssh to ask a licence with")
+ val drm = MediaDrm(WIDEVINE)
+ log("5 widevine level: ${runCatching { drm.getPropertyString("securityLevel") }.getOrNull()}")
+ runCatching { drm.setPropertyString("securityLevel", "L3") }
+ log("5 level for licence test: ${runCatching { drm.getPropertyString("securityLevel") }.getOrNull()}")
+ drm.setOnKeyStatusChangeListener({ _, _, keys, _ ->
+ keys.forEach { key ->
+ log("5 key ${key.keyId.joinToString("") { "%02x".format(it) }} status ${key.statusCode}")
+ }
+ }, android.os.Handler(android.os.Looper.getMainLooper()))
+ val session = drm.openSession()
+ try {
+ val request = drm.getKeyRequest(
+ session,
+ Base64.decode(pssh, Base64.DEFAULT),
+ "audio/mp4",
+ MediaDrm.KEY_TYPE_STREAMING,
+ null,
+ )
+ val response = http.newCall(
+ Request.Builder()
+ .url("$SPCLIENT/widevine-license/v1/audio/license")
+ .header("Authorization", "Bearer $token")
+ .post(request.data.toRequestBody("application/octet-stream".toMediaType()))
+ .build(),
+ ).execute()
+ val licence = response.body?.bytes() ?: ByteArray(0)
+ log("5 licence: HTTP ${response.code}, ${licence.size} bytes")
+ if (response.isSuccessful) {
+ runCatching { drm.provideKeyResponse(session, licence) }
+ .onSuccess { log("5 licence accepted by the device: keys loaded"); Thread.sleep(500) }
+ .onFailure { log("5 licence refused by the device: $it") }
+ }
+ } finally {
+ drm.closeSession(session)
+ drm.close()
+ }
+
+ // 6. Whether ExoPlayer plays it: eight seconds, quietly.
+ // if (cdn != null) playFor(cdn, token)
+ }
+
+ @androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class)
+ private fun playFor(cdn: String, token: String) {
+ val main = android.os.Handler(android.os.Looper.getMainLooper())
+ main.post {
+ // Measures what the decoder hands over, before the speaker: silence
+ // here is a decryption that "worked" and produced nothing.
+ var peak = 0
+ var frames = 0L
+ val meter = object : androidx.media3.exoplayer.audio.TeeAudioProcessor.AudioBufferSink {
+ override fun flush(sampleRateHz: Int, channelCount: Int, encoding: Int) {
+ log("6 pcm: $sampleRateHz Hz, $channelCount ch, encoding $encoding")
+ }
+ override fun handleBuffer(buffer: java.nio.ByteBuffer) {
+ val shorts = buffer.duplicate().order(java.nio.ByteOrder.nativeOrder()).asShortBuffer()
+ while (shorts.hasRemaining()) {
+ val v = kotlin.math.abs(shorts.get().toInt())
+ if (v > peak) peak = v
+ frames++
+ }
+ }
+ }
+ val renderers = object : androidx.media3.exoplayer.DefaultRenderersFactory(appContext!!) {
+ override fun buildAudioSink(
+ context: Context,
+ enableFloatOutput: Boolean,
+ enableAudioTrackPlaybackParams: Boolean,
+ ) = androidx.media3.exoplayer.audio.DefaultAudioSink.Builder(context)
+ .setAudioProcessors(arrayOf(androidx.media3.exoplayer.audio.TeeAudioProcessor(meter)))
+ .build()
+ }
+ // Widevine L3, the software level Chrome uses: with L1 the keys only
+ // decrypt inside the hardware's protected path, and the ordinary
+ // audio decoder was handed zeros.
+ val drm = androidx.media3.exoplayer.drm.DefaultDrmSessionManager.Builder()
+ .setUuidAndExoMediaDrmProvider(androidx.media3.common.C.WIDEVINE_UUID) { uuid ->
+ androidx.media3.exoplayer.drm.FrameworkMediaDrm.newInstance(uuid).apply {
+ // setPropertyString("securityLevel", "L3")
+ }
+ }
+ .build(
+ androidx.media3.exoplayer.drm.HttpMediaDrmCallback(
+ "$SPCLIENT/widevine-license/v1/audio/license",
+ androidx.media3.datasource.DefaultHttpDataSource.Factory(),
+ ).apply { setKeyRequestProperty("Authorization", "Bearer $token") },
+ )
+ val sources = androidx.media3.exoplayer.source.DefaultMediaSourceFactory(appContext!!)
+ .setDrmSessionManagerProvider { drm }
+ val player = androidx.media3.exoplayer.ExoPlayer.Builder(appContext!!, renderers)
+ .setMediaSourceFactory(sources)
+ .build()
+ player.addAnalyticsListener(object : androidx.media3.exoplayer.analytics.AnalyticsListener {
+ override fun onAudioDecoderInitialized(
+ eventTime: androidx.media3.exoplayer.analytics.AnalyticsListener.EventTime,
+ decoderName: String,
+ initializedTimestampMs: Long,
+ initializationDurationMs: Long,
+ ) { log("6 decoder: $decoderName") }
+ override fun onAudioInputFormatChanged(
+ eventTime: androidx.media3.exoplayer.analytics.AnalyticsListener.EventTime,
+ format: androidx.media3.common.Format,
+ decoderReuseEvaluation: androidx.media3.exoplayer.DecoderReuseEvaluation?,
+ ) { log("6 input format: ${format.sampleMimeType} codecs=${format.codecs} ch=${format.channelCount} drm=${format.drmInitData?.schemeType} init=${format.initializationData.map { it.size }}") }
+ override fun onDrmKeysLoaded(eventTime: androidx.media3.exoplayer.analytics.AnalyticsListener.EventTime) { log("6 drm keys loaded") }
+ override fun onDrmSessionManagerError(eventTime: androidx.media3.exoplayer.analytics.AnalyticsListener.EventTime, error: Exception) { log("6 drm error: $error") }
+ override fun onAudioCodecError(eventTime: androidx.media3.exoplayer.analytics.AnalyticsListener.EventTime, audioCodecError: Exception) { log("6 codec error: $audioCodecError") }
+ })
+ player.addListener(object : androidx.media3.common.Player.Listener {
+ override fun onPlaybackStateChanged(state: Int) { log("6 state=$state pos=${player.currentPosition}") }
+ override fun onPlayerError(error: androidx.media3.common.PlaybackException) { log("6 error: ${error.errorCodeName} ${error.cause}") }
+ })
+ player.volume = 0f
+ player.setMediaItem(
+ androidx.media3.common.MediaItem.Builder()
+ .setUri(cdn)
+ .setMimeType(androidx.media3.common.MimeTypes.AUDIO_MP4)
+ .setDrmConfiguration(
+ androidx.media3.common.MediaItem.DrmConfiguration.Builder(androidx.media3.common.C.WIDEVINE_UUID)
+ .setLicenseUri("$SPCLIENT/widevine-license/v1/audio/license")
+ .setLicenseRequestHeaders(mapOf("Authorization" to "Bearer $token"))
+ .build(),
+ )
+ .build(),
+ )
+ player.prepare()
+ player.play()
+ main.postDelayed({
+ log("6 before seek: peak=$peak over $frames samples, pos=${player.currentPosition}")
+ peak = 0
+ frames = 0
+ player.seekTo(60_000)
+ }, 4_000)
+ main.postDelayed({
+ log("6 after 10 s: playing=${player.isPlaying} pos=${player.currentPosition} format=${player.audioFormat?.sampleMimeType} ${player.audioFormat?.sampleRate} ch=${player.audioFormat?.channelCount}")
+ log("6 pcm peak=$peak of 32767 over $frames samples")
+ player.release()
+ }, 10_000)
+ }
+ }
+
+ /**
+ * Google's own Widevine test stream, to tell this phone's decryption from
+ * Spotify's files: if this decodes and Spotify's does not, the files are
+ * the difference.
+ */
+ @androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class)
+ private fun playReference() {
+ val main = android.os.Handler(android.os.Looper.getMainLooper())
+ main.post {
+ var peak = 0
+ val meter = object : androidx.media3.exoplayer.audio.TeeAudioProcessor.AudioBufferSink {
+ override fun flush(sampleRateHz: Int, channelCount: Int, encoding: Int) {}
+ override fun handleBuffer(buffer: java.nio.ByteBuffer) {
+ val shorts = buffer.duplicate().order(java.nio.ByteOrder.nativeOrder()).asShortBuffer()
+ while (shorts.hasRemaining()) { val v = kotlin.math.abs(shorts.get().toInt()); if (v > peak) peak = v }
+ }
+ }
+ val renderers = object : androidx.media3.exoplayer.DefaultRenderersFactory(appContext!!) {
+ override fun buildAudioSink(c: Context, f: Boolean, p: Boolean) =
+ androidx.media3.exoplayer.audio.DefaultAudioSink.Builder(c)
+ .setAudioProcessors(arrayOf(androidx.media3.exoplayer.audio.TeeAudioProcessor(meter)))
+ .build()
+ }
+ val player = androidx.media3.exoplayer.ExoPlayer.Builder(appContext!!, renderers).build()
+ player.volume = 0f
+ player.addListener(object : androidx.media3.common.Player.Listener {
+ override fun onPlayerError(error: androidx.media3.common.PlaybackException) { log("R error ${error.errorCodeName} ${error.cause}") }
+ })
+ player.setMediaItem(
+ androidx.media3.common.MediaItem.Builder()
+ .setUri("https://storage.googleapis.com/wvmedia/cenc/h264/tears/tears_aac.mpd")
+ .setDrmConfiguration(
+ androidx.media3.common.MediaItem.DrmConfiguration.Builder(androidx.media3.common.C.WIDEVINE_UUID)
+ .setLicenseUri("https://proxy.uat.widevine.com/proxy?video_id=2015_tears&provider=widevine_test")
+ .build(),
+ )
+ .build(),
+ )
+ player.prepare()
+ player.play()
+ val tick = object : Runnable {
+ var n = 0
+ override fun run() {
+ log("R t=${n}s pos=${player.currentPosition} playing=${player.isPlaying} peak=$peak tracks=${player.currentTracks.groups.map { it.type }}")
+ peak = 0
+ if (++n < 25) main.postDelayed(this, 1_000) else player.release()
+ }
+ }
+ main.postDelayed(tick, 1_000)
+ }
+ }
+
+ private var appContext: Context? = null
+
+ private fun get(url: String, token: String?, json: Boolean): Pair<Int, String?> {
+ val request = Request.Builder().url(url).apply {
+ token?.let { header("Authorization", "Bearer $it") }
+ if (json) header("Accept", "application/json")
+ }.build()
+ return http.newCall(request).execute().use { it.code to it.body?.string() }
+ }
+
+ /** A track's base62 id as the 32 hex digits the metadata endpoint wants. */
+ private fun gidOf(base62: String): String {
+ val alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ var value = BigInteger.ZERO
+ for (char in base62) value = value.multiply(BigInteger.valueOf(62)).add(BigInteger.valueOf(alphabet.indexOf(char).toLong()))
+ return value.toString(16).padStart(32, '0')
+ }
+}
diff --git a/app/src/main/java/dev/lelonio/square/playback/LibrespotPlayer.kt b/app/src/main/java/dev/lelonio/square/playback/LibrespotPlayer.kt
index f096f30..ee8ca65 100644
--- a/app/src/main/java/dev/lelonio/square/playback/LibrespotPlayer.kt
+++ b/app/src/main/java/dev/lelonio/square/playback/LibrespotPlayer.kt
@@ -1427,6 +1427,12 @@ class LibrespotPlayer(
} else if (refusalShown) {
return
}
+ // The whole account refused: there is another way to play it.
+ if (account) {
+ dev.lelonio.square.backend.spotify.SpotifyWebPlayback.reportAccountRefused()
+ refusalShown = true
+ return
+ }
refusalShown = true
android.widget.Toast.makeText(
appContext,
diff --git a/app/src/main/java/dev/lelonio/square/playback/PlaybackService.kt b/app/src/main/java/dev/lelonio/square/playback/PlaybackService.kt
index 5b680dd..00a4fb9 100644
--- a/app/src/main/java/dev/lelonio/square/playback/PlaybackService.kt
+++ b/app/src/main/java/dev/lelonio/square/playback/PlaybackService.kt
@@ -329,6 +329,15 @@ class PlaybackService : MediaLibraryService() {
}
}
+ // Spotify refusing this account every key (#35): what the engine was
+ // about to play goes over to the web player's way of playing it.
+ scope.launch {
+ dev.lelonio.square.backend.spotify.SpotifyWebPlayback.accountRefused.collect {
+ runCatching { moveToWebPlayback() }
+ .onFailure { android.util.Log.w(TAG, "web playback: $it") }
+ }
+ }
+
// The end-of-track timer, watched by position.
//
// It used to wait for the player to report moving on by itself, and
@@ -532,7 +541,7 @@ class PlaybackService : MediaLibraryService() {
* neither backend's player can open them. So what decides this is not only
* the setting but what is being played; see [ensurePlayerFor].
*/
- private enum class PlayerKind { SPOTIFY, YOUTUBE, LOCAL, VIDEO }
+ private enum class PlayerKind { SPOTIFY, YOUTUBE, LOCAL, VIDEO, SPOTIFY_WEB }
private var playerKind = PlayerKind.SPOTIFY
@@ -661,7 +670,17 @@ class PlaybackService : MediaLibraryService() {
val wanted = if (firstUri != null && dev.lelonio.square.data.LocalLibrary.isLocal(firstUri)) {
PlayerKind.LOCAL
} else {
- kindFor(container.preferences.backend.value)
+ kindFor(container.preferences.backend.value).let { kind ->
+ // An account Spotify refuses its keys goes on playing the web
+ // player's way, once the engine is up to lend it a token.
+ if (kind == PlayerKind.SPOTIFY && webPlaybackNeeded() &&
+ (librespot != null || parkedSpotify != null)
+ ) {
+ PlayerKind.SPOTIFY_WEB
+ } else {
+ kind
+ }
+ }
}
if (wanted == playerKind) return
@@ -685,6 +704,39 @@ class PlaybackService : MediaLibraryService() {
backendId: dev.lelonio.square.backend.BackendId,
): androidx.media3.common.Player = buildPlayer(kindFor(backendId))
+ private fun webPlaybackNeeded(): Boolean =
+ container.preferences.backend.value == dev.lelonio.square.backend.BackendId.SPOTIFY &&
+ dev.lelonio.square.backend.spotify.SpotifyWebPlayback.needed(this)
+
+ /**
+ * Carries the engine's queue, track and position over to the web player.
+ *
+ * The engine's items name their songs and nothing more; ExoPlayer plays an
+ * address, so each is given its own name as one, which the web player's
+ * resolver turns into its MP4 file.
+ */
+ private suspend fun moveToWebPlayback() {
+ if (playerKind != PlayerKind.SPOTIFY) return
+ val engine = librespot ?: return
+ val items = (0 until engine.mediaItemCount).map { index ->
+ val item = engine.getMediaItemAt(index)
+ item.buildUpon().setUri(item.mediaId).build()
+ }
+ if (items.isEmpty()) return
+ val index = engine.currentMediaItemIndex.coerceIn(0, items.lastIndex)
+ val position = engine.currentPosition.coerceAtLeast(0)
+ android.util.Log.i(TAG, "keys refused to the account: playing ${items.size} tracks the web player's way")
+ swapPlayer(PlayerKind.SPOTIFY_WEB, restore = false)
+ player.setMediaItems(items, index, position)
+ player.prepare()
+ player.play()
+ android.widget.Toast.makeText(
+ this,
+ getString(dev.lelonio.square.R.string.web_playback_on),
+ android.widget.Toast.LENGTH_LONG,
+ ).show()
+ }
+
private fun buildPlayer(
kind: PlayerKind,
): androidx.media3.common.Player = when (kind) {
@@ -754,6 +806,24 @@ class PlaybackService : MediaLibraryService() {
PlayerKind.SPOTIFY -> buildBackendPlayer(dev.lelonio.square.backend.BackendId.SPOTIFY)
PlayerKind.YOUTUBE -> buildBackendPlayer(dev.lelonio.square.backend.BackendId.YOUTUBE_MUSIC)
+
+ // Spotify the way its web player plays it, for an account refused its
+ // keys; see SpotifyWebPlayback. The engine stays parked behind it, for
+ // the catalogue and for the token the licence is asked with.
+ PlayerKind.SPOTIFY_WEB -> {
+ librespot = null
+ playerKind = kind
+ dev.lelonio.square.backend.spotify.SpotifyWebPlayback.create(
+ this,
+ playbackHost.looper,
+ LocalPlayerFactory.renderers(playbackHost),
+ ).also { built ->
+ built.playbackParameters = androidx.media3.common.PlaybackParameters(
+ AudioEffects.speed.value,
+ AudioEffects.pitch.value,
+ )
+ }
+ }
}
private fun buildBackendPlayer(
@@ -849,7 +919,7 @@ class PlaybackService : MediaLibraryService() {
// song comes back — it is also what the whole catalogue is read
// through while the video plays.
val parking = librespot != null &&
- (kind == PlayerKind.LOCAL || kind == PlayerKind.VIDEO)
+ (kind == PlayerKind.LOCAL || kind == PlayerKind.VIDEO || kind == PlayerKind.SPOTIFY_WEB)
if (parking) {
runCatching { player.playWhenReady = false }
parkedSpotify = librespot
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index f7c79f8..b6530a2 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -479,4 +479,5 @@
<string name="video_unavailable">Das offizielle Video kann nicht abgespielt werden: Das Video des Songs wird gezeigt.</string>
<string name="added_to_queue">Zur Warteschlange hinzugefügt: %s</string>
<string name="videos">Videos</string>
+ <string name="web_playback_on">Spotify verweigert diesem Konto die Schlüssel für die Songs: Sie werden wie im Webplayer abgespielt. Spotify Connect und Downloads sind so nicht verfügbar.</string>
</resources>
diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml
index bab747c..1b86009 100644
--- a/app/src/main/res/values-es/strings.xml
+++ b/app/src/main/res/values-es/strings.xml
@@ -485,4 +485,5 @@
<string name="video_unavailable">El vídeo oficial no se puede reproducir: se muestra el vídeo de la canción.</string>
<string name="added_to_queue">Añadido a la cola: %s</string>
<string name="videos">Vídeos</string>
+ <string name="web_playback_on">Spotify niega a esta cuenta las claves de las canciones: se reproducen como en el reproductor web. Spotify Connect y las descargas no están disponibles así.</string>
</resources>
diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml
index 31bb8c6..9d54554 100644
--- a/app/src/main/res/values-fr/strings.xml
+++ b/app/src/main/res/values-fr/strings.xml
@@ -479,4 +479,5 @@
<string name="video_unavailable">La vidéo officielle ne peut pas être lue : affichage de la vidéo du titre.</string>
<string name="added_to_queue">Ajouté à la file d\'attente : %s</string>
<string name="videos">Vidéos</string>
+ <string name="web_playback_on">Spotify refuse à ce compte les clés des titres : ils sont lus comme dans le lecteur web. Spotify Connect et les téléchargements ne sont pas disponibles ainsi.</string>
</resources>
diff --git a/app/src/main/res/values-hi/strings.xml b/app/src/main/res/values-hi/strings.xml
index 63cf17e..7b38864 100644
--- a/app/src/main/res/values-hi/strings.xml
+++ b/app/src/main/res/values-hi/strings.xml
@@ -494,4 +494,5 @@
<string name="video_unavailable">आधिकारिक वीडियो नहीं चल सकता: गाने का वीडियो दिखाया जा रहा है।</string>
<string name="added_to_queue">कतार में जोड़ा गया: %s</string>
<string name="videos">वीडियो</string>
+ <string name="web_playback_on">Spotify इस खाते को गानों की कुंजियाँ नहीं दे रहा: उन्हें वेब प्लेयर की तरह चलाया जा रहा है। इस तरह Spotify Connect और डाउनलोड उपलब्ध नहीं हैं।</string>
</resources>
diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml
index 5fd057e..d4e4cac 100644
--- a/app/src/main/res/values-it/strings.xml
+++ b/app/src/main/res/values-it/strings.xml
@@ -480,4 +480,5 @@
<string name="video_unavailable">Il video ufficiale non può essere riprodotto: mostro il video del brano.</string>
<string name="added_to_queue">Aggiunto in coda: %s</string>
<string name="videos">Video</string>
+ <string name="web_playback_on">Spotify rifiuta a questo account le chiavi per i brani: li riproduco come fa il web player. In questa modalità Spotify Connect e i download non sono disponibili.</string>
</resources>
diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml
index b1a3e09..17db49e 100644
--- a/app/src/main/res/values-pt/strings.xml
+++ b/app/src/main/res/values-pt/strings.xml
@@ -479,4 +479,5 @@
<string name="video_unavailable">O vídeo oficial não pode ser reproduzido: mostrando o vídeo da música.</string>
<string name="added_to_queue">Adicionado à fila: %s</string>
<string name="videos">Vídeos</string>
+ <string name="web_playback_on">O Spotify recusa a esta conta as chaves das músicas: elas tocam como no reprodutor web. Spotify Connect e downloads não estão disponíveis assim.</string>
</resources>
diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml
index 73e0583..6226fc1 100644
--- a/app/src/main/res/values-ru/strings.xml
+++ b/app/src/main/res/values-ru/strings.xml
@@ -506,4 +506,5 @@
<string name="video_unavailable">Официальное видео недоступно: показано видео трека.</string>
<string name="added_to_queue">Добавлено в очередь: %s</string>
<string name="videos">Видео</string>
+ <string name="web_playback_on">Spotify не выдаёт этому аккаунту ключи для треков: они воспроизводятся как в веб-плеере. Spotify Connect и загрузки так недоступны.</string>
</resources>
diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml
index c67eb88..028de90 100644
--- a/app/src/main/res/values-tr/strings.xml
+++ b/app/src/main/res/values-tr/strings.xml
@@ -492,4 +492,5 @@
<string name="video_unavailable">Resmi video oynatılamıyor: şarkının kendi videosu gösteriliyor.</string>
<string name="added_to_queue">Sıraya eklendi: %s</string>
<string name="videos">Videolar</string>
+ <string name="web_playback_on">Spotify bu hesaba şarkı anahtarlarını vermiyor: şarkılar web oynatıcıdaki gibi çalınıyor. Bu şekilde Spotify Connect ve indirmeler kullanılamaz.</string>
</resources>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 6b87d30..0cb6edf 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -507,4 +507,5 @@
<string name="added_to_queue">Added to queue: %s</string>
<string name="videos">Videos</string>
<string name="device_this_app" translatable="false">%1$s (Square)</string>
+ <string name="web_playback_on">Spotify refuses this account the keys its songs need: playing them the way the web player does. Spotify Connect and downloads are not available this way.</string>
</resources>