Open talha01sayed opened 3 years ago
This is my singleton class
object KohiiProvider {
private val capsule: Capsule<Kohii, Pair<Context, MediaSourceFactory>> =
Capsule(creator = { (context, factory) ->
createKohii(context, mediaSourceFactoryCreator = { factory })
})
private fun get(context: Context, factory: MediaSourceFactory) = capsule.get(context to factory)
operator fun get(context: Context) = get(context, ProgressiveMediaSource.Factory {
val dataSource = DefaultHttpDataSourceFactory("appPackageName",
DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS,
true)
val dataSourceFactory = DefaultDataSourceFactory(
context,
null,
dataSource
)
dataSourceFactory.createDataSource()
})
}
This is my fragment code. both fragments have the same code
val kohii = KohiiProvider[requireContext()] kohii.register(this, memoryMode = MemoryMode.INFINITE, activeLifecycleState = Lifecycle.State.RESUMED) .addBucket(viewPager) passengersAdapter = EpisodeAdapter(this, categoryId, viewModel, kohii) viewPager.adapter = passengersAdapter.withLoadStateHeaderAndFooter( header = PassengersLoadStateAdapter { passengersAdapter.retry() }, footer = PassengersLoadStateAdapter { passengersAdapter.retry() } ) binding.viewPager.offscreenPageLimit = 2
This is my both adapter code
kohii.setUp(videoFile) { tag = "video::$position" threshold = 0.5F preload = true repeatMode = Common.REPEAT_MODE_ONE artworkHintListener = object : Playback.ArtworkHintListener { override fun onArtworkHint( playback: Playback, shouldShow: Boolean, position: Long, state: Int ) { // holder.binding.thumbnail.isVisible = playback.playable?.isPlaying() == false } } controller = controller(kohiiCanStart = true, kohiiCanPause = true) { playback, _ -> val playable = playback.playable ?: return@controller holder.binding.container.setOnClickListener { if (playable.isPlaying()) playback.manager.pause(playable) else playback.manager.play(playable) } } }.bind(holder.binding.playerView)
Hi there, Thanks for this great library. I am using kohii-sample-tiktok code but also I am using it in two tabs with view pager and FragmentPagerAdapter both tabs have TikTok like videos UI. But the problem I am facing is
I have added the code of kohii-sample-tiktok in both fragments but I am getting this issue. If I comment code from one fragment then other will work. Please help.