Giter Site home page Giter Site logo

eneim / kohii Goto Github PK

View Code? Open in Web Editor NEW
368.0 22.0 49.0 40.49 MB

Android Video Playback made easy.

Home Page: https://eneim.github.io/kohii/

License: Apache License 2.0

Kotlin 97.41% Java 2.43% Shell 0.16%
android mediaplayer exoplayer recyclerview scrollview auto playback

kohii's Introduction

Kohii

kohii (コーヒー、[ko̞ːçiː])

Kohii

Video playback for Android made easy.

Maven Central

Kohii is a powerful, easy to use and extensible Video playback library. Kohii provides powerful features out of the box, including

  1. Easy to start: just one line to start a Video playback.
  2. Automatic playback experience on RecyclerView, NestedScrollView, ViewPager2, etc.
  3. Configuration change handling works out of the box, including the transition from local playback to fullscreen playback and vice versa.
  4. Feature-rich sample app that covers either simple or advance use cases.
  5. Extension-based structure, including default implementations that support ExoPlayer, AndroidX Media2, YouTube Player SDK.

Demo

Automatic playback Playback continuity (Seamless fullscreen)

Setup

Add to your module's build.gradle dependencies

// Update top level build.gradle
allprojects {
  repositories {
    mavenCentral()
  }
}
// Add these to app level build.gradle (or to module that will use Kohii)
implementation "im.ene.kohii:kohii-core:1.4.0.2017001" // core library
implementation "im.ene.kohii:kohii-exoplayer:1.4.0.2017001" // default support for ExoPlayer
implementation "com.google.android.exoplayer:exoplayer:2.17.1" // required ExoPlayer implementation.

Kohii uses Kotlin language with some Java 8 features so you will need to include the following options to your module's build.gradle:

android {
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }

  kotlinOptions {
    jvmTarget = "1.8"
  }
}

Start a playback

// Kotlin
// 1. Initialization in Fragment or Activity
val kohii = Kohii[this@Fragment]
kohii.register(this /* Fragment or Activity */).addBucket(this.recyclerView)

// 2. In ViewHolder or Adapter: bind the video to the PlayerView inside a child of the RecyclerView.
kohii.setUp(videoUrl).bind(playerView)
// Java
// 1. Initialization in Fragment or Activity
Kohii kohii = Kohii.get(this);
kohii.register(this).addBucket(this.recyclerView);

// 2. In ViewHolder or Adapter: bind the video to the PlayerView inside a child of the RecyclerView.
kohii.setUp(videoUrl).bind(playerView);

Requirements

Kohii works on Android 4.4+ (API level 19+) and on Java 8+. It is recommended to use Kohii using Kotlin.

The core library doesn't come with any actual playback logic. Actual implementation comes with extension libraries. The extensions require corresponding 3rd libraries: kohii-exoplayer will requires exoplayer, kohii-androidx will requires androidx.media2.

kohii's People

Contributors

eneim avatar sdex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kohii's Issues

How can i use PlayerControlView in kohii

Im trying to add the controller bar at bottom of playerview but nothing happens, i tryed to use inside of playerview just using controller_layout_id and then tryed another way using PlayerControlView and nothing happned on both and i cnat see the bar.
I need to implement something different?

Android Studio Cannot find Kohi after update news Kohi version

after update kohii in my build gradle module. android studio cannot find any Kohii library..
this is my implementation build gradle
implementation "im.ene.kohii:kohii:1.0.0.2010004-A11"
implementation "com.google.android.exoplayer:exoplayer:2.10.4"

build errors

hey @eneim !
I was trying to test out your solution in a recycler view (just like instagram plays/pauses videos)

on this line
Kohii kohii = new Kohii(this.getContext());
I get this:
Kohii(android.context.Contex) has private access in kohii.v1.exoplayer.Kohii

here is my grade build dependencies:

// ExoPlayer
def exo_player_version = '2.11.2'
implementation "com.google.android.exoplayer:exoplayer-core:$exo_player_version"
implementation "com.google.android.exoplayer:exoplayer-ui:$exo_player_version"
implementation "com.google.android.exoplayer:exoplayer-dash:$exo_player_version"
implementation "com.google.android.exoplayer:exoplayer-hls:$exo_player_version"
implementation "com.google.android.exoplayer:exoplayer-smoothstreaming:$exo_player_version"

// ExoPlayer extension for instagram like playable videos in recyclerView
implementation "im.ene.kohii:kohii-core:1.0.0.2010004-B2" // core library
implementation "im.ene.kohii:kohii-exoplayer:1.0.0.2010004-B2" // default support for ExoPlayer

// implementation "com.google.android.exoplayer:exoplayer:2.10.4" // required ExoPlayer implementation.

but I get this error:

AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"/Users/na/.gradle/caches/transforms-2/files-2.1/fe80929c59f3fa8dceee63b3420012ea/kohii-exoplayer-1.0.0.2010004-B2/res/layout/kohii_player_spherical_view.xml","position":{"startLine":17}}],"original":"/Users/na/.gradle/caches/transforms-2/files-2.1/fe80929c59f3fa8dceee63b3420012ea/kohii-exoplayer-1.0.0.2010004-B2/res/layout/kohii_player_spherical_view.xml:18: AAPT: error: 'spherical_view' is incompatible with attribute surface_type (attr) enum [none=0, spherical_gl_surface_view=3, surface_view=1, texture_view=2, video_decoder_gl_surface_view=4].\n ","tool":"AAPT"}

on Pause screen goes black

Hi First of all Thanks to you for such an amazing library. In my comparison, this was the best among all others.
My issue is when I try to pause video it has a black background instead of the current frame in Exo player I don't want to cover it up with thumbnail. can you please help me here I am using both Kohli and Unofficial YTplayer from the experiments have same issue in both places.
Please help me It's important for me.

[Question] Kohii release/cleanup

Hi, there is an issue on a lot of devices like Samsung J7/A10 that have small memory for video codec. I'm using Kohii in a carousel with multiple videos and then I'm opening another screen/fragment with single a MediaPlayer. The MediaPlayer crashes with error (1, -5001) from the codec saying there's not enough memory for the codec.

How can Kohii be released in onPause/onStop? I tried kohii.cleanUp() but seems that it doesn't release all the players and codec resources.

controller not working without tag in Binder.Option?

I implemented kohii with ViewPager2 but when using tag in Binder.Option its save the current track position of every video which I don't want because of memory limitation. Hence i removed the tag from Binder.Option

When I removed the tag, the controller is also not going to work?

How I can prevent to store the current track position/seek from videoplayer, however the controller should work?

Heres my code with tag and controller

kohii.setUp(url) {
                preload = true
                artworkHintListener = this@VideoViewHolder
                repeatMode = Common.REPEAT_MODE_ONE
                controller = object : Playback.Controller {
                override fun kohiiCanPause(): Boolean = true

                override fun kohiiCanStart(): Boolean = true

                override fun setupRenderer(playback: Playback, renderer: Any?) {
                    itemView.playerContainer.setOnClickListener {
                        val playable = playback.playable?: return@setOnClickListener
                        if (playable.isPlaying()) playback.manager.pause(playable)
                        else playback.manager.play(playable)

                    }
                }

                override fun teardownRenderer(playback: Playback, renderer: Any?) {
                    itemView.playerContainer.setOnClickListener(null)
                }
            }
        }.bind(playerView)

Muted videos are stealing audio focus from other apps

If I am playing audio in another app, and start a video with kohii, the audio focus is lost from the other app.

I am calling kohii.applyVolumeInfo(VolumeInfo(mute = true), manager, Scope.GLOBAL) to mute the videos.

Do you know how I can avoid requesting audio focus so the audio will continue in the background app?

State dose not change of previous video

Hi, thanks for kohii, love using it but I am facing below issue

If I pause certain video in view pager and move to next video and again go back to previous video it's still in pause state, kindly help me how to change the state and auto play the previous video.

Out of Memory issue with MemoryMode config

Hi,

I am seeing an out of memory issue on Android 7 device when using memory mode setting. As per docs, it says the memory mode can make sure such errors don't occur. Not sure if this is a bug in the memory mode code. Plz investigate.

This is my Kohii code:

Kohii kohii = Kohii.get(context);
        kohii.register(fragment, MemoryMode.NORMAL).addBucket(view);
        kohii.setUp(Uri.parse(linkedVideos.get(i).video_url), options -> {
            options.setPreload(true);
            return null;
        })
                .bind(playerView, null);

Error:

2020-10-10 17:19:05.416 21941-22322/com.rollup E/ExoPlayerImplInternal: Source error.
    com.google.android.exoplayer2.upstream.Loader$UnexpectedLoaderException: Unexpected OutOfMemoryError: Failed to allocate a 82 byte allocation with 3880 free bytes and 3KB until OOM
        at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:411)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
        at java.lang.Thread.run(Thread.java:761)
     Caused by: java.lang.OutOfMemoryError: Failed to allocate a 82 byte allocation with 3880 free bytes and 3KB until OOM
        at java.lang.StringFactory.newStringFromBytes(StringFactory.java:79)
        at com.android.okhttp.okio.Buffer.readString(Buffer.java:582)
        at com.android.okhttp.okio.Buffer.readUtf8(Buffer.java:557)
        at com.android.okhttp.okio.Buffer.readUtf8Line(Buffer.java:618)
        at com.android.okhttp.okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:203)
        at com.android.okhttp.internal.http.HttpConnection.readHeaders(HttpConnection.java:220)
        at com.android.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:199)
        at com.android.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:80)
        at com.android.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:942)
        at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:818)
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:480)
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:422)
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:538)
        at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
        at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java)
        at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:294)
        at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:257)
        at com.google.android.exoplayer2.upstream.cache.CacheDataSource.openNextSource(CacheDataSource.java:455)
        at com.google.android.exoplayer2.upstream.cache.CacheDataSource.open(CacheDataSource.java:284)
        at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:83)
        at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:934)
        at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:381)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
        at java.lang.Thread.run(Thread.java:761) 

Kohii is playing video in background.

I'm using kohii inside fragment in recyclerview. I have bottom navigation activity in which I'm using .show() and .hide() to change fragment.

Current behavior:

Video is playing on hide fragment.

Expected behavior:

Video must pause on hide fragment and resume on show fragment.

how to know progress for video??

Hi, I have a question.
I do not know if this is the right place for the question.
My question is
how can I show my video progress?
I can't find it.

sorry. poor my English. thank you

Video does not fill container

This is not much of an issue, but when I play a video in a container, it doesn't fill up the container. There is about some vertical padding (8dp) on the video when it starts playing. Not sure if this is an issue with the resolution of the video or it is just how the library works.

Change video uri when rotate screen

I want to know if i can change a video uri when the screen rotate(one uri in landscape and another in portrait), i try to bind again the player and show me an error:

java.lang.IllegalArgumentException: Failed requirement.
        at kohii.v1.core.Binder.providePlayable(Binder.kt:72)
        at kohii.v1.core.Binder.bind(Binder.kt:52)
        at com.goodtest.utils.StaggeredRecyclerViewAdapterHomeMemorySlider$15$1.onPaused(StaggeredRecyclerViewAdapterHomeMemorySlider.java:2562)
        at kohii.v1.core.Playback.onPlayerStateChanged(Playback.kt:400)
        at kohii.v1.core.PlayerEventListeners.onPlayerStateChanged(Interfaces.kt:118)
        at com.google.android.exoplayer2.ExoPlayerImpl.lambda$setPlayWhenReady$0(ExoPlayerImpl.java:254)
        at com.google.android.exoplayer2.-$$Lambda$ExoPlayerImpl$OKMPvkXpqXeKaJZFBZ8m9YfNXpE.invokeListener(Unknown Source:4)
        at com.google.android.exoplayer2.BasePlayer$ListenerHolder.invoke(BasePlayer.java:165)
        at com.google.android.exoplayer2.ExoPlayerImpl.invokeAll(ExoPlayerImpl.java:825)
        at com.google.android.exoplayer2.ExoPlayerImpl.lambda$notifyListeners$6(ExoPlayerImpl.java:718)
        at com.google.android.exoplayer2.-$$Lambda$ExoPlayerImpl$DrcaME6RvvSdC72wmoYPUB4uP5w.run(Unknown Source:4)
        at com.google.android.exoplayer2.ExoPlayerImpl.notifyListeners(ExoPlayerImpl.java:728)
        at com.google.android.exoplayer2.ExoPlayerImpl.notifyListeners(ExoPlayerImpl.java:718)
        at com.google.android.exoplayer2.ExoPlayerImpl.setPlayWhenReady(ExoPlayerImpl.java:254)
        at com.google.android.exoplayer2.SimpleExoPlayer.updatePlayWhenReady(SimpleExoPlayer.java:1224)
        at com.google.android.exoplayer2.SimpleExoPlayer.setPlayWhenReady(SimpleExoPlayer.java:921)
        at kohii.v1.exoplayer.PlayerViewBridge.pause(PlayerViewBridge.kt:160)
        at kohii.v1.core.AbstractPlayable.onPause(AbstractPlayable.kt:81)
        at kohii.v1.internal.PlayableDispatcher.justPause(PlayableDispatcher.kt:136)
        at kohii.v1.internal.PlayableDispatcher.pause$kohii_core_release(PlayableDispatcher.kt:109)
        at kohii.v1.core.Group.refresh(Group.kt:171)
        at kohii.v1.core.Group.handleMessage(Group.kt:50)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6680)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

There is a method or something i can do in kohii to do that?

Sync project with gradle gets "For input string: " Error

Hi, eneim.

I just download the newest release version which you publish 20 days ago. i tried to open it in Android studio but got sync error imediately and cannot open.

the error look like this. i did not change any file of your release.

69d5cd084812ee8fb0113657f38e846

c58d8e39ccadc26aa1bef0809344922

Preload next video

When scrolling the RecyclerView, I want the beginning of the next video to be preloaded to the cache so it will play immediately.

video replay when notifyitemchange is called [solved]

in your sample Class Rebinder have Renderer : Any like this ->
data class Rebinder<RENDERER : Any>( val tag: String, val rendererType: Class<RENDERER> )
but, in new release class Rebinder is already change like this ->
data class Rebinder( val tag: String, val rendererType: Class<*> )
so that make me confuse to following your sample .

How to pass authorization header in the library?

@eneim
Usually we used below in exoplayer,

  val videoSource: MediaSource = ProgressiveMediaSource.Factory(
      DataSource.Factory {
        val dataSource: HttpDataSource = DefaultHttpDataSource("com.example")
        // Set a custom authentication request header.
        dataSource.setRequestProperty("Authorization", bearerToken)
        dataSource
      }
  ).createMediaSource(Uri.parse(streamUri))

Now my question is how to add authorization while initiating. I got this one which is used to prepare sources

kohii.setUp(streamUri)

video not play when orientation is Landscape

i try your library for playvideo in recyclerview. but the problem is when orientation change to landscape the video is not auto play, maybe this cause my VideoViewholder height is so big. see this pictures

and i want to ask, how to pause and resume the video manual ? cause i need to pause and play in some event. thanks for this awesome library

play / pause when clicked

In my fragment i've done

val kohii = Kohii[this]
val manager = kohii.register(this).addBucket(binding.recyclerView)

then I pass them to my adapter like

 val adapter = MainTimelineAdapter(timelineList, kohii, manager)

on my adapter i have done

        kohii.setUp(videoUrl!!) {
            tag = "${videoUrl}+${position}"
            threshold = .8F
        }.bind(holder.binding.videoExoplayer){ playback ->
            val playable = playback.playable
            val myController = MyController(playable, manager)
            holder.binding.videoExoplayer.setOnClickListener(myController)
            KParameter.Kind.INSTANCE
        }

where myController looks like

class MyController(
    val playable: Playable?,
    val manager: Manager
) : View.OnClickListener, Playback.Controller {

    override fun kohiiCanStart() = true

    override fun kohiiCanPause() = true

    override fun onClick(v: View?) {
        if (playable != null) {
            val playing =playable.isPlaying()
            if (playable.isPlaying())
                manager.pause(playable)
            else
                manager.play(playable)
        }
    }
}

I want it to play and pause the video when the video is clicked, but it is actually doing nothing, even with manager and playable beeing not null...

I really dont know what I am doing wrong in here

ViewPager2 support

I want to use kohii with ViewPager2(because I want use vertical paging).

I cloned viewpager2 of google code and modified RecyclerView access modifier with public and setted host as RecyclerView in ViewPager2.

Then it worked.

I have no idea about side effect about that now...

Do you have any plan to support ViewPager2 with Kohii??

How to survive orientation but clear cache when closing screen

Hello,
I am currently using this setup with a tag, to survive the orientation change.
image
And that is working fine.

Now I am trying to clear stored information when the user is leaving the screen so that it will be played from the beginning next time user opens it, like this
image

But I cannot figure out a way to clear cached information for the tag.
What is the proper way to clear cache?

Thanks in advance.

The last video in the recycler view doesn't play.

I have a recycler view which contains a TextView along with the PlayerView and everything is working fine except that the last video in the recycler view doesn't play. I think that's because I noticed that the video only starts playing when the PlayerView is in focus but since the last item in the recycler view stays at the end, it doesn't come in the middle of the screen to get focus. Is there a work around for this?

Overlapping videos when resize_mode="zoom"

I don't know if this is an issue with Kohii per-se (or with the ExoPlayer backend itself).

When we change the resize mode of PlayerView's such that they zoom in to fill the whole container size, potentially cropping if needed to maintain the video's aspect ratio (this is achieved using resize_mode="zoom"), if we have multiple video containers and these containers are close enough, their video feeds overlap, as can be seen in the screenshot below.

Screenshot from 2020-07-13 11-00-14

By the way, thanks so much, amazing library!!

(And feel free to close this issue should the problem be with the underlying ExoPlayer - I just thought this should be worth some investigation at the Kohii level).

when I open the downloaded source from Android Studio 3.5.3, I meet an error

I has been looking for the solution in viewpager2 + video player, but the Kohii seems to be awesome for me.
I'd like to use Kohii, but when I open the downloaded source from Android Studio 3.5.3, I meet the follow error. Could you help me how to fix it?

ERROR: Plugin [id: 'org.gradle.kotlin.kotlin-dsl', version: '1.3.3'] was not found in any of the following sources:

  • Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
  • Plugin Repositories (could not resolve plugin artifact 'org.gradle.kotlin.kotlin-dsl:org.gradle.kotlin.kotlin-dsl.gradle.plugin:1.3.3')
    Searched in the following repositories:
    Gradle Central Plugin Repository

스크린샷 2020-02-16 15 02 20

ERROR: For input string: ""

String lookUpProf(String propertyName, String defaultValue) {
def propertyValue = project.properties[propertyName]
return propertyValue != null ? propertyValue : defaultValue
}

Exo player hls data source request headers?

Is it possible to setup request headers like this

private fun buildMediaSource(uri: Uri): MediaSource {
        return HlsMediaSource.Factory { dataType: Int ->
            val dataSource: HttpDataSource =
                DefaultHttpDataSource(Util.getUserAgent(getApplication(), "aliunid android"))

            dataSource.setRequestProperty(
                "Authorization",
                "Bearer ${tokenPreferences.accessToken}"
            )
            dataSource.setRequestProperty("SIOT-License", preferencesManager.licence)
            dataSource
        }.createMediaSource(uri)
    }

audio and video resume play in background

open kohii + recyclerview -> when video play then click home button, and video will pause. then lock your screen (without open other app), -> un-loack your sceen -> the video will auto resume (with audio)..

this happen in your sample app with redmi Note 7 (android P). how to disable or make audio or video not running in background ??

Can't register in activity

Using the Java language,
Java8 use specified in gradle.

public class DetailActivity extends AppCompatActivity {

    private ViewPager2 viewpager2;
    private Kohii kohii;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.detail_activity);

        detail_viewpager2 = findViewById(R.id.detail_viewpager2);

        kohii = Kohii.get(this);
        kohii.register(this).addBucket(detail_viewpager2);
    }
}

kohii.register( >>> this <<<)

I get an error here

Using kohii in 2 activities

Im having an issue about using kohi in 2 activities.

The problem is when i first open the activity 1 works fine, then open the activity 2 and works fine too but.. when i try to open again activity 1 it crash with this message

java.lang.IllegalArgumentException: Failed requirement.
at kohii.v1.core.Binder.providePlayable(Binder.kt:72)
at kohii.v1.core.Binder.bind(Binder.kt:52)

What it means about "Failed requirement".

Looping

In my scenario I have a recyclerview, with an com.google.android.exoplayer2.ui.PlayerView in each item. I set it up in java like this

kohii.setUp(videoUrl).bind(playerView, new Function1<Playback, Unit>() {
                @Override
                public Unit invoke(Playback playback) {
                    return null;
                }
            });

Is there a way I can have it looping if the user keeps that one item in viewport ? right now the ended callback is called and it stops.

LE: found the second parameter for setUp that is options.

, new Function1<Binder.Options, Unit>() {
                @Override
                public Unit invoke(Binder.Options options) {
                    options.setRepeatMode(Common.REPEAT_MODE_ALL);
                    options.setArtworkHintListener(new Playback.ArtworkHintListener() {
                        @Override
                        public void onArtworkHint(boolean b, long l, int i) {
                            
                        }
                    });
                    return null;
                }
            }

ArtworkHintListener

what does it do ?

In the callback onArtworkHint, other than a boolean flag shouldShow which is a hint from system about if the artwork should be shown or hidden, there is also position which is the current position of the Video, and state which is current state of the player. Using these values, you can have your own behavior, other than just show/hide the ImageView.

Project not build with new version

`
Could not determine the dependencies of task ':app:compileDebugKotlin'.

Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Could not find kohii.v1:kohii-core:unspecified.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/kohii/v1/kohii-core/unspecified/kohii-core-unspecified.pom
- https://dl.google.com/dl/android/maven2/kohii/v1/kohii-core/unspecified/kohii-core-unspecified.jar
- https://jcenter.bintray.com/kohii/v1/kohii-core/unspecified/kohii-core-unspecified.pom
- https://jcenter.bintray.com/kohii/v1/kohii-core/unspecified/kohii-core-unspecified.jar
Required by:
project :app > im.ene.kohii:kohii-exoplayer:1.0.0.2010004-B1
`

there are some issues i found when using kohii with recycler view.

Hi, eneim.

I found some issues when i am using kohii with recycler view, here is the scenario.

in my recycler view, i need to update the data every 5 minutes in case there are some more datas come from remote server and each time the recycler get new datas, it triggers 'notifyDataSetChanged' function, then the adapter's 'onBindViewHolder' is triggered. in the 'onBindViewHolder', i used 'kohii.setup().bind()' function to bind the video to my playerView. so that means, every time the recycler view is updated, the kohii will call the bind() function.

so here is the problem, in the kohii.bind() function, there is a providePlayable() function and in this function, it need the playable of same tag must have the same Media data - 'require(cache.media == media)', but every time my recycler view is being updated, the media url data is different because i have to play different video. so my application gets to crash.

can you help me with this issue?

stop / pause the video

Hi eneim, can you show me the way to stop the video when user click the playerView.

I tried methods like pause() in manager but not ganna work and i cannot find way like stop() method in exoplayer.

Adding new video to adapter continues to play the previous top cached video.

First of all thank you for this awesome library. I am facing an issue when i add a new video to the adapter the previous top video is the one which continues to play.

How can i refresh the cache tags. e.g like update the tag 0 with the a null cache since its a new video and update the previous cache 0 to cache 1 and so on ? When i refresh the items on the adapter.

Some Video Pause forever when i try to scroll up

First of all Big Thanks buddy for this library, it's awesome.

1)only some video pause, how can I solve this

  1. distance between two slid screen is huge, I want to show 2 slid below just the first slide, how can I achieve?

  2. I searched other close issue but never found, how to pause the video when tabs are changed

ezgif com-video-to-gif

First video not playing in the nested recyclerview

Hi
First of all I wanna thank you for this amazing library
Videos that are visible right away and are on the top of the list in a nested recyclerview wont play until you scroll down the list and then scroll up again so that views are attached again .
EDIT: The code set up

Heres how I set Kohii in main activity and add the main recyclerview to the bucket. I pass the instance of Kohii and the manager in the adapter

        val kohii= Kohii[this]
        val manager=kohii.register(this).addBucket(recyclerView)
         adapter = TweetsPageAdapter(this,kohii,manager)
        recyclerView.layoutManager = LinearLayoutManager(this)
        recyclerView.adapter = adapter

Then I add the nested recyclerview to the bucket in this adapter's viewholder

class TweetViewHolder(var view: View) : RecyclerView.ViewHolder(view) {
        fun bind(tweet: Tweet?) {
            view.tweet.text = tweet?.text
            val dpUrl=tweet?.user?.profile_image_url_https
            val newDpurl= dpUrl?.replace("_normal","")
            Glide.with(view).load(newDpurl).into(view.imageViewDp)
            view.screenName.text="@"+tweet?.user?.screen_name
            view.name.text=tweet?.user?.name
            val recyclerView = view.recyclerView
            manager.addBucket(recyclerView)
            val noOfCol= Utility.calculateNoOfColumns(view.context,200f);
            val child=SpanningGridLayoutManager(view.context,noOfCol)
            recyclerView.layoutManager=child
            child.initialPrefetchItemCount=4
            val adapter= MediaAdapter(context,kohii)
           ................................................................
           .................................................................
}

The video viewholder in the MediaAdapter is as follow

 class SimpleExoPlayerViewHolder internal constructor(itemView: View) :
    RecyclerView.ViewHolder(itemView) {
    var playerView: PlayerView

    fun bind(kohii: Kohii,item: Uri) {
        kohii.setUp(item).bind(playerView);

    }

    init {
        playerView = itemView.findViewById(R.id.playerView)
    }
} 

Feature: smooth binding switching

As current implementation will wait for the container to be attached, we need a mechanism to retain the Playable during the switch.

Crash on Android 6

I use lib version 1.0.0.2906-A09 and faced a crash on my OnePlus X device with Android Marshmallow:

java.lang.NoSuchMethodError: No virtual method remove(Ljava/lang/Object;Ljava/lang/Object;)Z in class Ljava/util/WeakHashMap; or its super classes (declaration of 'java.util.WeakHashMap' appears in /system/framework/core-libart.jar) at kohii.v1.PlaybackManager.onOwnerDestroy$kohii_release(PlaybackManager.kt:159) at kohii.v1.PlaybackManager_LifecycleAdapter.callMethods(PlaybackManager_LifecycleAdapter.java:43) at androidx.lifecycle.SingleGeneratedAdapterObserver.onStateChanged(SingleGeneratedAdapterObserver.java:29) at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:361) at androidx.lifecycle.LifecycleRegistry.backwardPass(LifecycleRegistry.java:316) at androidx.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.java:334) at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.java:145) at androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.java:131) at androidx.fragment.app.FragmentViewLifecycleOwner.handleLifecycleEvent(FragmentViewLifecycleOwner.java:51) at androidx.fragment.app.Fragment.performDestroyView(Fragment.java:2845) at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:947) at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1228) at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:434) at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2066) at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1856) at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1811) at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1717) at androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java:150) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5539) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.