<commit_before>package io.clappr.player.components

import android.widget.FrameLayout
import io.clappr.player.base.InternalEvent
import io.clappr.player.plugin.Loader
import io.clappr.player.base.Options
import io.clappr.player.base.UIObject
import io.clappr.player.playback.NoOpPlayback
import io.clappr.player.plugin.Plugin

class Container(val loader: Loader, val options: Options) : UIObject() {
    val plugins: List<Plugin>

    var playback: Playback? = null
        set(value) {
            if (playback != value) {
                trigger(InternalEvent.WILL_CHANGE_PLAYBACK.value)

                field = value

                trigger(InternalEvent.DID_CHANGE_PLAYBACK.value)
            }
        }

    val frameLayout: FrameLayout
        get() = view as FrameLayout

    override val viewClass: Class<*>
        get() = FrameLayout::class.java

    init {
        plugins = loader.loadPlugins(this)
        val source = options.source
        val mimeType = options.mimeType
        if (source != null) {
            load(source, mimeType)
        }
    }

    fun load(source: String, mimeType: String? = null): Boolean {
        var supported = playback?.load(source, mimeType) ?: false
        if (!supported) {
            playback = loader.loadPlayback(source, mimeType, options)
            if (playback?.name == NoOpPlayback.name) {
                playback = null
            }
            supported = playback != null
        }
        return supported
    }

    override fun render(): Container {
        val playback = this.playback
        playback?.let {
            frameLayout.addView(playback.view)
            playback.render()
        }
        return this
    }
}<commit_msg>feat(container): place playback view behind other views<commit_after>package io.clappr.player.components

import android.os.Build
import android.widget.FrameLayout
import io.clappr.player.base.InternalEvent
import io.clappr.player.plugin.Loader
import io.clappr.player.base.Options
import io.clappr.player.base.UIObject
import io.clappr.player.playback.NoOpPlayback
import io.clappr.player.plugin.Plugin

class Container(val loader: Loader, val options: Options) : UIObject() {
    val plugins: List<Plugin>

    var playback: Playback? = null
        set(value) {
            if (playback != value) {
                trigger(InternalEvent.WILL_CHANGE_PLAYBACK.value)

                field = value

                trigger(InternalEvent.DID_CHANGE_PLAYBACK.value)
            }
        }

    val frameLayout: FrameLayout
        get() = view as FrameLayout

    override val viewClass: Class<*>
        get() = FrameLayout::class.java

    init {
        plugins = loader.loadPlugins(this)
        val source = options.source
        val mimeType = options.mimeType
        if (source != null) {
            load(source, mimeType)
        }
    }

    fun load(source: String, mimeType: String? = null): Boolean {
        var supported = playback?.load(source, mimeType) ?: false
        if (!supported) {
            playback = loader.loadPlayback(source, mimeType, options)
            if (playback?.name == NoOpPlayback.name) {
                playback = null
            }
            supported = playback != null
        }
        return supported
    }

    override fun render(): Container {
        val playback = this.playback
        playback?.let {
            frameLayout.addView(playback.view)
            sendPlayBackViewToBack(playback)
            playback.render()
        }
        return this
    }

    private fun sendPlayBackViewToBack(playback: Playback) {
        val playBackViewIndex = frameLayout.indexOfChild(playback.view)

        var index = 0
        while (index < playBackViewIndex)
            frameLayout.getChildAt(index++).bringToFront()
    }
}
{'fraction_non_alphanumeric': 0.09196310935441371, 'fraction_numerical': 0.00026350461133069827, 'mean_word_length': 2.1925988225399498, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7589108', 'n_tokens_mistral': 1089, 'n_tokens_neox': 1052, 'n_words': 235}