Android library to auto-play/pause videos from url in recyclerview.

Overview

AutoplayVideos

API Android Arsenal Android Weekly AndroidDev Digest

Show some ❤️ and star the repo to support the project

GitHub stars GitHub forks GitHub watchers GitHub followers
Twitter Follow

This library is created with the purpose to implement recyclerview with videos easily.

It is targeted at solving following problems:

  1. Flicker when scrolling.
  2. Lag or skipping frames when video starts.
  3. OutOfMemory errors.

And it has following features:

  1. Auto-play videos when in view.
  2. Auto-pause videos when not in view or partially in view.
  3. Mute/Un-mute videos.
  4. Option to play only first visible video.
  5. Download videos to local storage in background for faster loading.

Demo

autoplayvideos_demo

Download

Gradle

Step 1. Add the jCenter repository to your project-level build.gradle file

allprojects {
	repositories {
		jcenter()
	}
}

Step 2. Add the dependency to your app-level build.gradle file:

dependencies {
	 compile 'com.allattentionhere:autoplayvideos:0.2.0'
}

Or Maven

<dependency>
  <groupId>com.allattentionhere</groupId>
  <artifactId>autoplayvideos</artifactId>
  <version>0.2.0</version>
  <type>pom</type>
</dependency>

Permissions

Add below permissions to AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Usage

Add AAH_VideoImage to your xml file for single list item single_card.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <android.support.v7.widget.CardView
        android:id="@+id/card_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
       
       <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical">

             <FrameLayout
                android:layout_width="300dp"
                android:layout_height="150dp">

                <com.allattentionhere.autoplayvideos.AAH_VideoImage
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" />

                <ImageView
                    android:id="@+id/img_vol"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="right|bottom"
                    android:layout_margin="8dp"
                    android:src="@drawable/ic_unmute"/>
            </FrameLayout>

            <TextView
                android:id="@+id/tv"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center" />
		
        </LinearLayout>
    </android.support.v7.widget.CardView>
</LinearLayout>

Add AAH_CustomRecyclerView to your Activity layout xml MainActivity.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <com.allattentionhere.autoplayvideos.AAH_CustomRecyclerView
        android:id="@+id/rv_home"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
	
</LinearLayout>

Set Adapter with following specifics:

  1. Adapter should extend AAH_VideosAdapter.
  2. ViewHolder should extend AAH_CustomViewHolder.
  3. Set thumbnail image url and video url in onBindViewHolder method.
public class MyVideosAdapter extends AAH_VideosAdapter {

    private List<MyModel> list;
    Picasso picasso;

    public class MyViewHolder extends AAH_CustomViewHolder {
        final TextView tv;
	final ImageView img_vol,img_playback;
        boolean isMuted; //to mute/un-mute video (optional)
	
        public MyViewHolder(View x) {
            super(x);
            tv = ButterKnife.findById(x, R.id.tv);
	    img_vol = ButterKnife.findById(x, R.id.img_vol);
	    img_playback = ButterKnife.findById(x, R.id.img_playback);
        }
    }

    public MyVideosAdapter(List<MyModel> list_urls, Picasso p) {
        this.list = list_urls;
        this.picasso = p;
    }

    @Override
    public AAH_CustomViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.single_card, parent, false);
        return new MyViewHolder(itemView);
    }

    @Override
    public void onBindViewHolder(AAH_CustomViewHolder holder, int position) {
        ((MyViewHolder) holder).tv.setText(list.get(position).getName());

        //todo
        holder.setImageUrl(list.get(position).getImage_url());
        holder.setVideoUrl(list.get(position).getVideo_url());
        //load image/thumbnail into imageview
        if (list.get(position).getImage_url() != null && !list.get(position).getImage_url().isEmpty())
            picasso.load(holder.getImageUrl()).config(Bitmap.Config.RGB_565).into(holder.getAAH_ImageView());
    }
    
    @Override
    public int getItemCount() {
        return list.size();
    }

    @Override
    public int getItemViewType(int position) {
        return 0;
    }
}

Finally setActivity in your Activity before setting the adapter and (Optional) scroll programmatically to initiate videos on initial screen:

    recyclerView.setActivity(this); //todo before setAdapter
    recyclerView.setAdapter(mAdapter);

Play videos initially (Optional)

Call these two functions to start video playback when the screen launches and user hasn't scrolled.

recyclerView.smoothScrollBy(0,1);
recyclerView.smoothScrollBy(0,-1);

Play only 1st video (Optional)

Setting this parameter will play video only in 1st completely visible RecyclerView ViewHolder.

recyclerView.setPlayOnlyFirstVideo(true); // false by default

Download videos to local storage (Optional)

You can start downloading video in background on viewholder loaded. You can change download path.

recyclerView.setDownloadPath(Environment.getExternalStorageDirectory() + "/MyVideo"); //optional
recyclerView.setDownloadVideos(true); // false by default

Optionally you can start pre-downloading all the videos by passing list of URLs to function as below:

List<String> urls = new ArrayList<>();
 for (MyModel object : modelList) {
     if (object.getVideo_url() != null && object.getVideo_url().endsWith(".mp4"))
         urls.add(object.getVideo_url());
 }
recyclerView.preDownload(urls);

Add below permission to AndroidManifest.xml. Ask for runtime permission in devices on Marshmallow and above.

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Remove check for .mp4 (Optional)

By default it checks for url to end with .mp4 else it is not considered as video URL. You can override this by setting parameter as below. Please use this with caution and make sure you provide video URL only.

recyclerView.setCheckForMp4(false); // true by default

Pause videos manually (Optional)

Call the following method to stop the videos when Activity/Fragment stops (User receives call, minimizes app etc)

    @Override
    protected void onStop() {
        super.onStop();
        recyclerView.stopVideos();
    }

Resume videos when app resumes (Optional)

Call the following method to resume videos when App resumes (opening app after minimizing it, etc)

    @Override
    protected void onResume() {
        super.onResume();
        recyclerView.playAvailableVideos(0);
    }

Play partially visible video (Optional)

Call the following method to set the percentage of view that needs to be visible for video to start playing.

    recyclerView.setVisiblePercent(50);

Get callbacks when videos starts and pauses

You can override the below methods of AAH_CustomViewHolder to get callback when video starts to play or pauses.

	@Override
        public void videoStarted() {
            super.videoStarted();
            img_playback.setImageResource(R.drawable.ic_pause);
            if (isMuted) {
                muteVideo();
                img_vol.setImageResource(R.drawable.ic_mute);
            } else {
                unmuteVideo();
                img_vol.setImageResource(R.drawable.ic_unmute);
            }
        }
        @Override
        public void pauseVideo() {
            super.pauseVideo();
            img_playback.setImageResource(R.drawable.ic_play);
        }

Play or pause videos manually

You can allow the user to play or pause any video by adding below code in onBindViewHolder:

	((MyViewHolder) holder).img_playback.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (holder.isPlaying()) {
                    holder.pauseVideo();
                    holder.setPaused(true);
                } else {
                    holder.playVideo();
                    holder.setPaused(false);
                }
            }
        });

Mute or Unmute the videos

Video can be muted/unmuted by adding below code in onBindViewHolder:

	holder.getAah_vi().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (((MyViewHolder) holder).isMuted) {
                    holder.unmuteVideo();
                    ((MyViewHolder) holder).img_vol.setImageResource(R.drawable.ic_unmute);
                } else {
                    holder.muteVideo();
                    ((MyViewHolder) holder).img_vol.setImageResource(R.drawable.ic_mute);
                }
                ((MyViewHolder) holder).isMuted = !((MyViewHolder) holder).isMuted;
            }
        });

Set looping on videos

Set looping on videos by adding below code in onBindViewHolder:

holder.setLooping(true); //optional - true by default

Cache Videos (Optional)

It is recommended to setDownloadVideos(value) to true. However if you do not want to use this option, we recommend you to use AndroidVideoCache library. Here is how you can use it along with our library:

Initilize HttpProxyCacheServer

Initilize HttpProxyCacheServer in your Application class and register Application class in your Manifest file.

public class MyApplication extends Application {
	private static HttpProxyCacheServer proxy;

	public static HttpProxyCacheServer getProxy() {
	    return proxy;
	}

	@Override
	public void onCreate() {
	    super.onCreate();
	    proxy = new HttpProxyCacheServer(this);
	}
}	

Set proxy video URL

In your VideosAdapter, set the Video URL as follows:

holder.setVideoUrl(MyApplication.getProxy().getProxyUrl(list.get(position).getVideo_url()+"")); // url should not be null

You can also use advanced options for caching that the library supports. Refer to their documentation for the same.

Use Cloudinary (Optional)

It is recommended to use Cloudinary.com to host your videos as it provides easy thumbnail-generation and resizing/cropping videos on-the-fly.

Changelog

Our other libraries

Apps by developer

Price Stalker Show Card Game Safio chat

License

Copyright 2017 Krupen Ghetiya

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Comments
  • NullPointer Exception

    NullPointer Exception

    I'm getting an internal NPE related with the uri when the source is set. I am sure that the uri is not null before set the video uri setVideoUrl(uri.toString());

    Could be the issue related with recycled view?

    Thank you so much

    Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.net.Uri.getScheme()' on a null object reference at android.media.MediaPlayer.setDataSource(MediaPlayer.java:989) at android.media.MediaPlayer.setDataSource(MediaPlayer.java:972) at com.allattentionhere.autoplayvideos.AAH_CustomVideoView.onSurfaceTextureAvailable(S:224) at android.view.TextureView.getHardwareLayer(TextureView.java:368) at android.view.View.updateDisplayListIfDirty(View.java:15219) at android.view.View.draw(View.java:16015) at android.view.ViewGroup.drawChild(ViewGroup.java:3765) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3555) at android.view.View.updateDisplayListIfDirty(View.java:15237) at android.view.View.draw(View.java:16015) at android.view.ViewGroup.drawChild(ViewGroup.java:3765) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3555) at android.view.View.draw(View.java:16248) at android.view.View.updateDisplayListIfDirty(View.java:15242) at android.view.View.draw(View.java:16015) at android.view.ViewGroup.drawChild(ViewGroup.java:3765) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3555) at android.view.View.draw(View.java:16248) at android.view.View.updateDisplayListIfDirty(View.java:15242) at android.view.View.draw(View.java:16015) at android.view.ViewGroup.drawChild(ViewGroup.java:3765) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3555) at android.view.View.updateDisplayListIfDirty(View.java:15237) at android.view.View.draw(View.java:16015) at android.view.ViewGroup.drawChild(ViewGroup.java:3765) at android.support.v7.widget.RecyclerView.drawChild(S:4581) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3555) at android.view.View.draw(View.java:16248) at android.support.v7.widget.RecyclerView.draw(S:3987) at android.view.View.updateDisplayListIfDirty(View.java:15242) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3749) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3729) at android.view.View.updateDisplayListIfDirty(View.java:15202) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3749) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3729) at android.view.View.updateDisplayListIfDirty(View.java:15202) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3749) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3729) at android.view.View.updateDisplayListIfDirty(View.java:15202) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3749) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3729) at android.view.View.updateDisplayListIfDirty(View.java:15202) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3749) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3729) at android.view.View.updateDisplayListIfDirty(View.java:15202) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3749) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3729) at android.view.View.updateDisplayListIfDirty(View.java:15202) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3749) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3729) at android.view.View.updateDisplayListIfDirty(View.java:15202) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3749) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3729) at android.view.View.updateDisplayListIfDirty(View.java:15202) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3749) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3729) at android.view.View.updateDisplayListIfDirty(View.java:15202) at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:281) at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:287) at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:322) at android.view.ViewRootImpl.draw(ViewRootImpl.java:2662) at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2481) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2091) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1127) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6156) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:892) at android.view.Choreographer.doCallbacks(Choreographer.java:704) at android.view.Choreographer.doFrame(Choreographer.java:640) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:878) 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:5628) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:853) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:737)

    opened by adalpari 10
  • UI Freezes if preDownload is disabled.

    UI Freezes if preDownload is disabled.

    In the example app, if you comment out the following part

    recyclerView.setDownloadPath(Environment.getExternalStorageDirectory() + "/MyVideo"); recyclerView.setDownloadVideos(true); // false by default

       `//extra - start downloading all videos in background before loading RecyclerView
       List<String> urls = new ArrayList<>();
       for (MyModel object : modelList) {
           if (object.getVideo_url() != null && object.getVideo_url().contains("http"))
               urls.add(object.getVideo_url());
       }
       recyclerView.preDownload(urls);`
    

    then the UI begins to freeze when a new video cell is scrolled into the screen until the video starts to play.

    opened by penumbram-zz 10
  • Image Loading

    Image Loading

    1. Whenever i tap on item or scroll the list image become invisible and if last item is image in list then it also become invisible. It will not show images properly. 2)When first time videos downloading at that time we can't scroll down the list the views stuck in application.
    opened by sundar-malya 8
  • Blank view

    Blank view

    This is in reference to a previous issue where I was using FirebaseRecyclerAdapter #33 . However, I've now created my own adapter and have successfully retrieved the database info into an ArrayList. The issue now is that the AAH_CustomRecyclerView is not being displayed, which therefore means the ViewHolder methods are not being called. In the design view for recyclerview my activity, this error is being displayed:

    The following classes could not be instantiated:
    - com.allattentionhere.autoplayvideos.AAH_CustomRecyclerView (Open Class, Show Exception, Clear Cache)
    - android.support.v7.widget.AppCompatTextView (Open Class, Show Exception, Clear Cache)
     Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE.  
    If this is an unexpected error you can also try to build the project, then manually refresh the layout.  Exception Details java.lang.NullPointerException   at
    android.os.storage.StorageManager.getVolumeList(StorageManager.java:922)   at android.os.Environment$UserEnvironment.getExternalDirs(Environment.java:87)   at android.os.Environment.getExternalStorageDirectory(Environment.java:404)   at com.allattentionhere.autoplayvideos.AAH_CustomRecyclerView.<init>(AAH_CustomRecyclerView.java:41)   at java.lang.reflect.Constructor.newInstance(Constructor.java:423)   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)   at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858)   at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)   at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)   at android.view.LayoutInflater.inflate(LayoutInflater.java:518)   at android.view.LayoutInflater.inflate(LayoutInflater.java:397) Copy stack to clipboard  
    

    And the view is being displayed as a grey box in the preview. When the app is run, nothing is displayed in that particular activity.

    Here's the code for my adapter and firebase database query: MultiViewTypeAdapter:

    public class MultiViewTypeAdapter extends AAH_VideosAdapter {
    
        List<Map<String, Object>> postsList;
        Context mContext;
    
        public static class VideoTypeViewHolder extends AAH_CustomViewHolder{
    
            final ImageView img_vol,img_playback;
            boolean isMuted;
    
            public VideoTypeViewHolder(View itemView) {
                super(itemView);
    
                img_vol = (ImageView) itemView.findViewById(R.id.img_vol);
                img_playback = (ImageView) itemView.findViewById(R.id.img_playback);
            }
    
            @Override
            public void videoStarted() {
                super.videoStarted();
                img_playback.setImageResource(R.drawable.ic_pause);
                if (isMuted) {
                    muteVideo();
                    img_vol.setImageResource(R.drawable.ic_mute);
                } else {
                    unmuteVideo();
                    img_vol.setImageResource(R.drawable.ic_unmute);
                }
            }
            @Override
            public void pauseVideo() {
                super.pauseVideo();
                img_playback.setImageResource(R.drawable.ic_play_circle);
            }
        }
    
        public MultiViewTypeAdapter(List<Map<String, Object>> data, Context context){
            this.postsList = data;
            this.mContext = context;
        }
    
        @Override
        public AAH_CustomViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.video_feed_item, parent, false);
            return new VideoTypeViewHolder(view);
        }
    
        @Override
        public void onBindViewHolder(AAH_CustomViewHolder holder, int position) {
            holder.setImageUrl(postsList.get(position).post_img);
            holder.setVideoUrl(postsList.get(position).post_video);
    
            if(postsList.get(position).post_img != null && !postsList.get(position).post_img.isEmpty()){
                GlideApp.with(mContext)
                        .load(holder.getImageUrl())
                        .into(holder.getAAH_ImageView());
            }
    
            holder.setLooping(true);
    
            ((VideoTypeViewHolder)holder).img_playback.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (holder.isPlaying()) {
                        holder.pauseVideo();
                        holder.setPaused(true);
                    } else {
                        holder.playVideo();
                        holder.setPaused(false);
                    }
                }
            });
    
            ((VideoTypeViewHolder) holder).img_vol.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (((VideoTypeViewHolder) holder).isMuted) {
                        holder.unmuteVideo();
                        ((VideoTypeViewHolder) holder).img_vol.setImageResource(R.drawable.ic_unmute);
                    } else {
                        holder.muteVideo();
                        ((VideoTypeViewHolder) holder).img_vol.setImageResource(R.drawable.ic_mute);
                    }
                    ((VideoTypeViewHolder) holder).isMuted = !((VideoTypeViewHolder) holder).isMuted;
                }
            });
    
            if (postsList.get(position).post_img == null) {
                ((VideoTypeViewHolder) holder).img_vol.setVisibility(View.GONE);
                ((VideoTypeViewHolder) holder).img_playback.setVisibility(View.GONE);
            } else {
                ((VideoTypeViewHolder) holder).img_vol.setVisibility(View.VISIBLE);
                ((VideoTypeViewHolder) holder).img_playback.setVisibility(View.VISIBLE);
            }
    
        }
    
        @Override
        public int getItemCount() {
            return postsList.size();
        }
    }
    

    Firebase Database Query

    postsQuery.addChildEventListener(new ChildEventListener() {
                @Override
                public void onChildAdded(DataSnapshot dataSnapshot, String s) {
    
                    Posts posts = dataSnapshot.getValue(Posts.class);
                    postsList.add(posts.toMap());
    
                    multiViewTypeAdapter = new MultiViewTypeAdapter(postsList, FeedListActivity.this);
                    multiViewTypeAdapter.notifyItemInserted(postsList.size());
    
                }
    
                @Override
                public void onChildChanged(DataSnapshot dataSnapshot, String s) {
                    multiViewTypeAdapter.notifyDataSetChanged();
                }
    
                @Override
                public void onChildRemoved(DataSnapshot dataSnapshot) {
    
                }
    
                @Override
                public void onChildMoved(DataSnapshot dataSnapshot, String s) {
    
                }
    
                @Override
                public void onCancelled(DatabaseError databaseError) {
                    throw databaseError.toException();
                }
            });
    
    
            recyclerView.setActivity(FeedListActivity.this);
            recyclerView.setCheckForMp4(false);
    
            recyclerView.setAdapter(multiViewTypeAdapter);
    
    opened by jeremy-jamez 8
  • RecyclerView Gone

    RecyclerView Gone

    1. I have implemented swipe to refresh and whenever i swipe from top 3 to 4 times the recyclerview will be gone the whole view become blank

    2. Sometimes i got the below error and app will crash:- UncaughtException: java.lang.OutOfMemoryError: Could not allocate JNI Env at java.lang.Thread.nativeCreate(Native Method) at java.lang.Thread.start(Thread.java:745) at com.allattentionhere.autoplayvideos.AAH_CustomRecyclerView.playAvailableVideos(AAH_CustomRecyclerView.java:91) at com.allattentionhere.autoplayvideos.AAH_CustomRecyclerView$1.onScrollStateChanged(AAH_CustomRecyclerView.java:76) at android.support.v7.widget.RecyclerView.dispatchOnScrollStateChanged(RecyclerView.java:4655) at android.support.v7.widget.RecyclerView.setScrollState(RecyclerView.java:1386) at android.support.v7.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:4791) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:926) at android.view.Choreographer.doCallbacks(Choreographer.java:735) at android.view.Choreographer.doFrame(Choreographer.java:664) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:912) at android.os.Handler.handleCallback(Handler.java:761) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:156) at android.app.ActivityThread.main(ActivityThread.java:6523) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831)

    opened by sundar-malya 7
  • Video is playing and scroll listener's first and last complete visible positions are always -1

    Video is playing and scroll listener's first and last complete visible positions are always -1

    Hi,

    I am trying to play videos but it is not working, i tried to figure out the issue and as far as i found is that scroll listener fist and last complete positions are always -1. and that is it not playing any video.

    Can you help me to resolve the error.

    Thanks

    opened by MustanserIqbal93 7
  • Avoid restarting video when it goes off and on screen?

    Avoid restarting video when it goes off and on screen?

    Is it possible to do a real pause of the video when it goes off screen, and when it goes on again, resume when it was paused? Right now videos restart from the beginning

    opened by amanzan 6
  • Add Media controller

    Add Media controller

    How to add media controller in AutoplayVideo lib? I fail to integrate video controller and horizontal progress of video duration? please help with this issue.

    opened by test220492 5
  •  recyclerView.stopVideos();

    recyclerView.stopVideos();

    recyclerView.stopVideos(); not working in fragments. I have two tabs when I swipe left videos still plays with audio. I put this in recyclerView.stopVideos(); in onPause & onStop. Please let me know the solution for this.

    opened by khopaderahul01 5
  • Null pointer Exception on scroll recyclerview.

    Null pointer Exception on scroll recyclerview.

    Hi, thanks for the amazing library, i have a multiple view type recyclerview, and i get a null pointer exception on scrolling. Here is the logcat printout

    FATAL EXCEPTION: main Process: com.rosius.tori, PID: 28476 java.lang.NullPointerException: Attempt to invoke virtual method 'com.allattentionhere.autoplayvideos.AAH_CustomVideoView com.allattentionhere.autoplayvideos.AAH_VideoImage.getCustomVideoView()' on a null object reference at com.allattentionhere.autoplayvideos.AAH_VideosAdapter.onViewDetachedFromWindow(AAH_VideosAdapter.java:26) at com.allattentionhere.autoplayvideos.AAH_VideosAdapter.onViewDetachedFromWindow(AAH_VideosAdapter.java:9) at android.support.v7.widget.RecyclerView.dispatchChildDetached(RecyclerView.java:6947) at android.support.v7.widget.RecyclerView$5.removeViewAt(RecyclerView.java:762) at android.support.v7.widget.ChildHelper.removeViewAt(ChildHelper.java:168) at android.support.v7.widget.RecyclerView$LayoutManager.removeViewAt(RecyclerView.java:8041) at android.support.v7.widget.RecyclerView$LayoutManager.removeAndRecycleViewAt(RecyclerView.java:8313) at android.support.v7.widget.LinearLayoutManager.recycleChildren(LinearLayoutManager.java:1368) at android.support.v7.widget.LinearLayoutManager.recycleViewsFromStart(LinearLayoutManager.java:1414) at android.support.v7.widget.LinearLayoutManager.recycleByLayoutState(LinearLayoutManager.java:1483) at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1542) at android.support.v7.widget.LinearLayoutManager.scrollBy(LinearLayoutManager.java:1330) at android.support.v7.widget.LinearLayoutManager.scrollVerticallyBy(LinearLayoutManager.java:1074) at android.support.v7.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:4838) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858) at android.view.Choreographer.doCallbacks(Choreographer.java:670) at android.view.Choreographer.doFrame(Choreographer.java:603) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844) 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:5417) 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)

    opened by trey-rosius 5
  • Why this library work only with internet connection?

    Why this library work only with internet connection?

    I spend a lot of time searching the issue in my code and the problem was the internet connection.

    With internet all work fine, but without connection all work bad.

    opened by sebamena 5
  • Video doesnot stoppped when app in background

    Video doesnot stoppped when app in background

    I am using recyclerview in fragment, when the app goes background or when new activity opens up the videos is playing continuously. its not stopping. Kindly help me to solve this issue

    opened by Narmadha24 0
  • Is there any way to play youtube videos?

    Is there any way to play youtube videos?

    I have trouble to play youtube videos. I found it great library for online videos but unfortunately, it doesn't play youtube videos.

    Who can explain about this? Thanks.

    opened by kpstar 1
  • java.lang.IllegalStateException: com.allattentionhere.autoplayvideos.AAH_CustomVideoView.onSurfaceTextureDestroyed

    java.lang.IllegalStateException: com.allattentionhere.autoplayvideos.AAH_CustomVideoView.onSurfaceTextureDestroyed

    Hi, I notice that quite a number of my app users are affected by this exception via Crashlytics:

    Non-fatal Exception: java.lang.IllegalStateException
           at android.media.MediaPlayer._stop(MediaPlayer.java)
           at android.media.MediaPlayer.stop + 1437(MediaPlayer.java:1437)
           at com.allattentionhere.autoplayvideos.AAH_CustomVideoView.onSurfaceTextureDestroyed + 256(AAH_CustomVideoView.java:256)
           at android.view.TextureView.releaseSurfaceTexture + 249(TextureView.java:249)
           at android.view.TextureView.onDetachedFromWindowInternal + 222(TextureView.java:222)
           at android.view.View.dispatchDetachedFromWindow + 17586(View.java:17586)
           at android.view.ViewGroup.dispatchDetachedFromWindow + 3756(ViewGroup.java:3756)
           at android.view.ViewGroup.dispatchDetachedFromWindow + 3756(ViewGroup.java:3756)
           at android.view.ViewGroup.dispatchDetachedFromWindow + 3756(ViewGroup.java:3756)
           at android.view.ViewGroup.removeViewInternal + 5320(ViewGroup.java:5320)
           at android.view.ViewGroup.removeViewAt + 5267(ViewGroup.java:5267)
           at androidx.recyclerview.widget.RecyclerView$5.removeViewAt + 877(RecyclerView.java:877)
           at androidx.recyclerview.widget.ChildHelper.removeViewAt + 168(ChildHelper.java:168)
           at androidx.recyclerview.widget.RecyclerView$LayoutManager.removeViewAt + 8374(RecyclerView.java:8374)
           at androidx.recyclerview.widget.RecyclerView$LayoutManager.removeAndRecycleViewAt + 8647(RecyclerView.java:8647)
           at androidx.recyclerview.widget.LinearLayoutManager.recycleChildren + 1369(LinearLayoutManager.java:1369)
           at androidx.recyclerview.widget.LinearLayoutManager.recycleViewsFromStart + 1415(LinearLayoutManager.java:1415)
           at androidx.recyclerview.widget.LinearLayoutManager.recycleByLayoutState + 1484(LinearLayoutManager.java:1484)
           at androidx.recyclerview.widget.LinearLayoutManager.fill + 1508(LinearLayoutManager.java:1508)
           at androidx.recyclerview.widget.LinearLayoutManager.scrollBy + 1331(LinearLayoutManager.java:1331)
           at androidx.recyclerview.widget.LinearLayoutManager.scrollVerticallyBy + 1075(LinearLayoutManager.java:1075)
           at androidx.recyclerview.widget.RecyclerView.scrollStep + 1832(RecyclerView.java:1832)
           at androidx.recyclerview.widget.RecyclerView$ViewFlinger.run + 5067(RecyclerView.java:5067)
           at android.view.Choreographer$CallbackRecord.run + 1008(Choreographer.java:1008)
           at android.view.Choreographer.doCallbacks + 804(Choreographer.java:804)
           at android.view.Choreographer.doFrame + 729(Choreographer.java:729)
           at android.view.Choreographer$FrameDisplayEventReceiver.run + 994(Choreographer.java:994)
           at android.os.Handler.handleCallback + 794(Handler.java:794)
           at android.os.Handler.dispatchMessage + 99(Handler.java:99)
           at android.os.Looper.loop + 176(Looper.java:176)
           at android.app.ActivityThread.main + 6662(ActivityThread.java:6662)
           at java.lang.reflect.Method.invoke(Method.java)
           at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run + 547(RuntimeInit.java:547)
           at com.android.internal.os.ZygoteInit.main + 873(ZygoteInit.java:873)
    

    The exception affect different devices from different brands (Xiaomi, Samsung, Motorola etc) with different Android versions (9, 8, 7, 6) but I'm not able to reproduce it myself. Any idea why this could happen?

    opened by waseefakhtar 0
Owner
Krupen Ghetiya
Krupen Ghetiya
Renderers is an Android library created to avoid all the boilerplate needed to use a RecyclerView/ListView with adapters.

Renderers Renderers is an Android library created to avoid all the RecyclerView/Adapter boilerplate needed to create a list/grid of data in your app a

Pedro Vicente Gómez Sánchez 1.2k Nov 19, 2022
:page_with_curl: [Android Library] Giving powers to RecyclerView

Android library that provides most common functions around recycler-view like Swipe to dismiss, Drag and Drop, Divider in the ui, events for when item

Nishant Srivastava 644 Nov 20, 2022
Android library for the adapter view (RecyclerView, ViewPager, ViewPager2)

Antonio Android library for the adapter view (RecyclerView, ViewPager, ViewPager2) Free from implementation of the adapter's boilerplate code ! Reuse

NAVER Z 106 Dec 23, 2022
An Adapter that allows a RecyclerView to be split into Sections with headers and/or footers. Each Section can have its state controlled individually.

⚠️ Archived: this repository is no longer going to be maintained. SectionedRecyclerViewAdapter An Adapter that allows a RecyclerView to be split into

Gustavo Pagani 1.7k Dec 21, 2022
Create a new adapter for a RecyclerView or ViewPager is now much easier.

Efficient Adapter for Android Create a new adapter for a RecyclerView or ViewPager is now much easier. Overview Create a list of elements into a Recyc

Stan Kocken 423 Sep 16, 2022
Rx based RecyclerView Adapter

RxRecyclerAdapter Rx based generic RecyclerView Adapter Library. How to use it? Example! Enable Databinding by adding these lines to your build.gradle

Ahmed Rizwan 193 Jun 18, 2022
This Repository simplifies working with RecyclerView Adapter

AutoAdapter This Repository simplifies working with RecyclerView Adapter Gradle: Add it in your root build.gradle at the end of repositories: allproj

George Dzotsenidze 151 Aug 15, 2021
Generic RecyclerView adapter

Generic RecyclerView Adapter. Lightweight library which simplifies creating RecyclerView adapters and illuminates writing boilerplate code. Creating a

Leonid Ustenko 77 Dec 24, 2022
Vector map library and writer - running on Android and Desktop.

Mapsforge See the integration guide and changelog. And read through how to contribute guidelines. If you have any questions or problems, don't hesitat

mapsforge 1k Jan 2, 2023
[] Easy Adapters library for Android

Deprecated Due to the growing use of the RecyclerView and the RecyclerView.Adapter provided adapter class, Easy-Adapter is now deprecated. Whilst the

ribot 425 Nov 25, 2022
This library provides GridAdapters(ListGridAdapter & CursorGridAdapter) which enable you to bind your data in grid card fashion within android.widget.ListView, Also provides many other features related to GridListView.

GridListViewAdapters This libarary enables you to implement GridView like card layout within ListView with added capabilites like Paginations, Additio

Biraj Patel 270 Nov 25, 2022
This library provides Easy Android ListView Adapters(EasyListAdapter & EasyCursorAdapter) which makes designing Multi-Row-Type ListView very simple & cleaner, It also provides many useful features for ListView.

EasyListViewAdapters Whenever you want to display custom items in listview, then only way to achieve this is to implement your own subclass of BaseAda

Biraj Patel 132 Nov 25, 2022
Open source routing engine for OpenStreetMap. Use it as Java library or server.

GraphHopper Routing Engine GraphHopper is a fast and memory efficient Java routing engine, released under Apache License 2.0. By default it uses OpenS

GraphHopper 4k Jan 7, 2023
The bullet proof, fast and easy to use adapter library, which minimizes developing time to a fraction...

FastAdapter The FastAdapter is here to simplify creating adapters for RecyclerViews. Don't worry about the adapter anymore. Just write the logic for h

Mike Penz 3.7k Jan 8, 2023
A library to make a mosaic with a preview of multiple images

Preview Image Collection Introduction Preview Image Collection is a library to draw a collage with a number of images like facebook preview album Inst

Agnaldo Pereira 50 Jun 13, 2022
Android - A ListView adapter with support for multiple choice modal selection

MultiChoiceAdapter MultiChoiceAdapter is an implementation of ListAdapter which adds support for modal multiple choice selection as in the native Gmai

Manuel Peinado Gallego 855 Nov 11, 2022
Adapter Kit is a set of useful adapters for Android.

Adapter Kit Adapter Kit is a set of useful adapters for Android. The kit currently includes, Instant Adapter Instant Cursor Adapter Simple Section Ada

Ragunath Jawahar 368 Nov 25, 2022
Simplify Adapter creation for your Android ListViews.

FunDapter takes the pain and hassle out of creating a new Adapter class for each ListView you have in your Android app. It is a new approach to custom

Ami Goldenberg 287 Dec 22, 2022
Generate data-view-binding adapters of android recycler view.

Items 这个库可以为 Android 的 RecyclerView 生成基于 Data-View-Binding 的 Adapter。 对比其他一些类似的开源库,它有以下的一些优势: 更好的拓展性。这个库不需要你继承特定的 Adapter 或 ViewHolder 类,你可以继承任何第三方提供的

nekocode 253 Nov 11, 2022