krupen / autoplayvideos Goto Github PK
View Code? Open in Web Editor NEWAndroid library to auto-play/pause videos from url in recyclerview.
License: Apache License 2.0
Android library to auto-play/pause videos from url in recyclerview.
License: Apache License 2.0
I'd like to know if it'd be possible to scale videos, specifically CENTER_CROP to keep the right ratio
sometimes i am using this codes, videos not appearing on the screen.
exoplayer library is most complicated than default android video stream system.
what do you think?
In your sample app, there is no full screenfor videos
When i tried to view more than 2 videos, the second video dont show and the videoplayer comes to blank.
I follow the examples, but the problem still appears.
When the activity is displayed, the items have a title, when the title is clicked, the cam opened and record the video and when finish, the video is displayed in the autoplayrecyclerview, but the video dont show automatic, and force to playvideo, but dont works.
When is only one video, all works fine, but if are two or more, i have problems to play videos correctly.
Hello,
When I use this library with set adapter, it works well. But when I use this library with swap adapter , it not working. Can you update and add support swapAdapter?
Thank you
Hello @Krupen !
First of all, great job!
Second of all: I cannot find in your lib any way to access all the functions needed to act on the video itself... And I'm referring to, for example, get the video's current position in order to resume playing it from that position, or get the original width and height of the playing video...
If I'm not mistaken, access to all these features could be granted just with a simple getter to the AAH_CustomVideoView's MediaPlayer instance, right?
Really hope to see those features in the very near future...
When i am scrolling recyclerview at that time last position video visible on first position ? How can i resolve it , I also put every if else condition properly still got this issue
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
Hi Sir , can you add a progressbar when video is loading like Facebook does please ?
Thanks you Sir
I'm trying to use this video view to play my own video but having no success i have tried this code
private void initVideoViews() {
tv = findViewById(R.id.tv);
img_vol = findViewById( R.id.img_vol);
img_playback = findViewById( R.id.img_playback);
aah_vi = (AAH_VideoImage) findViewById(R.id.video_player);
setImageUrl("https://pre00.deviantart.net/7a94/th/pre/i/2015/143/a/0/this_is_da_boomb__by_reptonic-d8uispv.png");
setVideoUrl("https://raw.githubusercontent.com/danikula/AndroidVideoCache/master/files/orange1.mp4");
Picasso.with(ImageDetailActivity.this).
load("https://pre00.deviantart.net/7a94/th/pre/i/2015/143/a/0/this_is_da_boomb__by_reptonic-d8uispv.png").config(Bitmap.Config.RGB_565).
into(aah_vi.getImageView());
setLooping(true);
playVideo();
}
First of all a great work. It worked very well with the URL's given in the demo application but when i tried to play videos and load images from amazon s3 server, the application hanged. I tried to reduce down the size to 5 items at a time but no luck. Then i opened only 2 url's - 1 as given in the demo app and other one from amazon s3. The 1st one worked very well but no luck with the 2nd one.
Any tips?
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)
Hey Krupen,
This library is working fine. Thanks for sharing this awesome library.
As per my app requirement i need to add Slider layout for images.
So how can I add this in your library.
Also where do I add download progress.
Please let me know if you have any suggestion or Idea for this asap.
Thanks.
It does not work with horizontal layout manager
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.
Hey,
Thanks for nice library. I am using this library into my project. Few minitues works fine, but after some time app go to freeze. I set the beow
holder.setLooping(false);
setDownloadVideos(false); // because of device memory issue
I got bellow error from logcat. Can you help me please?
java.lang.OutOfMemoryError:
at java.lang.Thread.nativeCreate (Native Method)
at java.lang.Thread.start (Thread.java:730)
at com.allattentionhere.autoplayvideos.AAH_CustomRecyclerView.playAvailableVideos (AAH_CustomRecyclerView.java:85)
at com.allattentionhere.autoplayvideos.AAH_CustomRecyclerView$1.onScrollStateChanged (AAH_CustomRecyclerView.java:70)
at android.support.v7.widget.RecyclerView.dispatchOnScrollStateChanged (RecyclerView.java:4759)
at android.support.v7.widget.RecyclerView.setScrollState (RecyclerView.java:1434)
at android.support.v7.widget.RecyclerView$ViewFlinger.fling (RecyclerView.java:4954)
at android.support.v7.widget.RecyclerView.fling (RecyclerView.java:2130)
at android.support.v7.widget.RecyclerView.onTouchEvent (RecyclerView.java:2994)
at android.view.View.dispatchTouchEvent (View.java:10081)
at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2779)
at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2408)
at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2785)
at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2422)
at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2785)
at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2422)
at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2785)
at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2422)
at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2785)
at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2422)
at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2785)
at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2422)
at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2785)
at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2422)
at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2785)
at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2422)
at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2785)
at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2422)
at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2785)
at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2422)
at com.android.internal.policy.DecorView.superDispatchTouchEvent (DecorView.java:435)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent (PhoneWindow.java:1836)
at android.app.Activity.dispatchTouchEvent (Activity.java:3063)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent (WindowCallbackWrapper.java:68)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent (WindowCallbackWrapper.java:68)
at com.android.internal.policy.DecorView.dispatchTouchEvent (DecorView.java:397)
at android.view.View.dispatchPointerEvent (View.java:10312)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent (ViewRootImpl.java:4949)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess (ViewRootImpl.java:4808)
at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:4315)
at android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:4368)
at android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:4334)
at android.view.ViewRootImpl$AsyncInputStage.forward (ViewRootImpl.java:4480)
at android.view.ViewRootImpl$InputStage.apply (ViewRootImpl.java:4342)
at android.view.ViewRootImpl$AsyncInputStage.apply (ViewRootImpl.java:4537)
at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:4315)
at android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:4368)
at android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:4334)
at android.view.ViewRootImpl$InputStage.apply (ViewRootImpl.java:4342)
at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:4315)
at android.view.ViewRootImpl.deliverInputEvent (ViewRootImpl.java:6844)
at android.view.ViewRootImpl.doProcessInputEvents (ViewRootImpl.java:6818)
at android.view.ViewRootImpl.enqueueInputEvent (ViewRootImpl.java:6761)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent (ViewRootImpl.java:7016)
at android.view.InputEventReceiver.dispatchInputEvent (InputEventReceiver.java:185)
at android.os.MessageQueue.nativePollOnce (Native Method)
at android.os.MessageQueue.next (MessageQueue.java:328)
at android.os.Looper.loop (Looper.java:148)
at android.app.ActivityThread.main (ActivityThread.java:6276)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:924)
Hi,
I am using firebase storage to store my videos, but the download URL it generates its a bit strange looks like this - "https://firebasestorage.googleapis.com/v0/b/predrink-dev.appspot.com/o/EVENT_FEED%2Fvideos%2F-KkKhw9KWq-lsnsXGjPH%2F1496951854596?alt=media&token=7e08cdb4-1a6c-4762-98ef-97bf8a2a7333" - so it doesn't end with .mp4 or any other media type, but the videos are .mp4 and when open the url in the browser the videos work.
Any idea how can i make this work for your library?
Thanks
Right now, as soon as any part of the video goes offscreen, the video is paused. Would it be possible to keep it playing until the video is completely offscreen? Let me know if you need further clarification.
Thanks a lot for your work, it's the only library that really helps handling videos in recyclerviews!
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
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)
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.
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
public class FeedAdapter extends AAH_VideosAdapter {
String TAG = getClass().getSimpleName();
Activity activity;
Globals globals;
private static final int SECOND_MILLIS = 1000;
private static final int MINUTE_MILLIS = 60 * SECOND_MILLIS;
private static final int HOUR_MILLIS = 60 * MINUTE_MILLIS;
private static final int DAY_MILLIS = 24 * HOUR_MILLIS;
ArrayList<FeedModel> feedList;
public class MyViewHolder extends AAH_CustomViewHolder {
TextView TxtPost, TxtLike, TxtComment, TxtName, TxtTime;
ImageView ImgPost, ImgLike, ImgComment;
CircularImageView ImgFphoto;
AAH_VideoImage view_video;
public MyViewHolder(View x) {
super(x);
TxtPost = ButterKnife.findById(x, R.id.TxtPost);
TxtLike = ButterKnife.findById(x, R.id.TxtLike);
TxtComment = ButterKnife.findById(x, R.id.TxtComment);
TxtName = ButterKnife.findById(x, R.id.TxtName);
TxtTime = ButterKnife.findById(x, R.id.TxtTime);
ImgPost = ButterKnife.findById(x, R.id.ImgPost);
ImgLike = ButterKnife.findById(x, R.id.ImgLike);
ImgComment = ButterKnife.findById(x, R.id.ImgComment);
ImgFphoto = ButterKnife.findById(x, R.id.ImgFphoto);
view_video = ButterKnife.findById(x, R.id.view_video);
}
}
public FeedAdapter(Activity activity, ArrayList<FeedModel> feedList) {
this.activity = activity;
this.feedList = feedList;
feedList.get(0).setFile("");
globals = ((Globals) activity.getApplicationContext());
}
@Override
public AAH_CustomViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.feed_layout, parent, false);
return new MyViewHolder(itemView);
}
@Override
public void onBindViewHolder(final AAH_CustomViewHolder holder, int position) {
final FeedModel item = feedList.get(position);
((MyViewHolder) holder).TxtName.setText(item.getName());
((MyViewHolder) holder).TxtPost.setText(item.getPost());
((MyViewHolder) holder).TxtLike.setText(item.getLike_count());
((MyViewHolder) holder).TxtComment.setText(item.getComment_count());
((MyViewHolder) holder).ImgLike.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
int likecount;
if (item.getIs_like() == 1) {
item.setIs_like(0);
likecount = Integer.parseInt(item.getLike_count());
item.setLike_count(String.valueOf(likecount - 1));
((MyViewHolder) holder).ImgLike.setImageResource(R.drawable.like);
likeUnlikepost(item.getPost_id());
notifyDataSetChanged();
} else {
item.setIs_like(1);
likecount = Integer.parseInt(item.getLike_count());
item.setLike_count(String.valueOf(likecount + 1));
((MyViewHolder) holder).ImgLike.setImageResource(R.drawable.liked);
likeUnlikepost(item.getPost_id());
notifyDataSetChanged();
}
}
});
//load image into imageview
if (item.getPhoto() != null && !item.getPhoto().isEmpty()) {
Picasso.with(activity).load(Constant.URL_USERPHOTO + item.getPhoto().replaceAll(" ", "%20")).into(((MyViewHolder) holder).ImgFphoto);
}
// time
if (item.getCreated() != null) {
long timeInMilliseconds = 0;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
Date mDate = sdf.parse(item.getCreated());
timeInMilliseconds = mDate.getTime();
String Timeago = getTimeAgo(timeInMilliseconds);
((MyViewHolder) holder).TxtTime.setText(Timeago);
} catch (ParseException e) {
e.printStackTrace();
}
}
if (item.getPost_type().matches("1")) {
// text only
} else if (item.getPost_type().matches("2")) {
// image only
holder.setImageUrl(Constant.URL_POSTFILE + item.getFile().replaceAll(" ", "%20"));
} else {
// video only
Log.e("Video", "URL : " + Constant.URL_POSTFILE + item.getFile().replaceAll(" ", "%20"));
holder.setImageUrl(Constant.URL_POSTFILE_THUMBNAIL + item.getThumbnail().replaceAll(" ", "%20"));
holder.setVideoUrl(Constant.URL_POSTFILE + item.getFile().replaceAll(" ", "%20"));
}
if (holder.getImageUrl() != null && holder.getImageUrl().length() > 0) {
Picasso.with(activity).load(holder.getImageUrl()).into(holder.getAAH_ImageView());
}
}
@Override
public int getItemCount() {
return feedList.size();
}
@Override
public int getItemViewType(int position) {
return 0;
}
}
Here, my other property remaining same just photo and video's positon are changed. when i am scrolling.
Hi,
I was wondering is there a way to automatically get the height from the video according to its aspect ratio and set it, because now it only works with a fixed height. Is this possible?
Thanks
when I give the direct link like https://firebasestorage.googleapis.com/v0/b/flickering-heat-5334.appspot.com/o/demo1.mp4?.....,this link is working in autoplay, but when I give the other extension like mov,it doesn't work.
Please help.
Thankyou.
Hey,
This library working fine. Thanks for sharing this awesome library.
This library in only work for video playing. Can you help me how can I use different view holder type with your library? E.x
Recyclerview
item-1 : video view
item-2 : Only text view
item-3: video view
item-4: Imageview etc.
that's mean I want to use different type view holder with your library ?
Hi,
Whenever a video is playing and i minimize the app, the playback doesn't stop an i can hear the sound still playing. Can you fix this please?
Thanks
autoplayVideos library is not working with android 7.0.
can you check it?
hi how can i load all videos from my local storage of device folder and display list of videos from local storage folder and play it
grid view position white screen showing few sec after autoplay video -- Need clarity | solution
While playing video in recycler view, AutoPlayVideo is blocking main thread, which is annoying.
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.
I'm looking for a way to mute the videos by default. It would be nice to have an isMuted flag like the isLooping one, that can be used right after the mediaPlayer was created. Currently the vh.muteVideo() method doesn't work when called from within the onBindViewHolder method.
Hi,
Thanks for this awesome library. I first checked out your sample app, that worked perfectly.
I couldnt get it working for my app, also pardon me if I share too much info as I am a newbie to android and not really sure where th issue lies, my app design or the library. My app has the following structure-
SignInActivity->Main nav_drawer activity-> 3 Fragments & 1 activity (VideoActivity).
Case 1: I used the gradle import option and defined the adapter, model and the res files. The video activity loaded. However, only the first video played.
Case 2: I manually imported the autoplayvideos from the sample app into my app. Then defined the adapter, model and res files. Video activity loaded and ALL videos played.
Is there some issue with the current version that I got via gradle?
Thanks
I read before : #48
recyclerView.stopVideos() not working in fragment and main activity. I made RecyclerView as static and called from main activity give same exception. I use Bottom Navigation View.
Hi,
I've try to get get percentage of view in position of adapter. For example, if percentage is 50 view in position of adapter, then play video. Is there any way to do that?
Thank you.
Awesome library till day found for playing video with downloading feature but facing minor issue,
I have set setDownloadVideos(true). And now I deleted videos from gallery. Then It is not getting downloaded again. Any solution for this, videos are not shown in gallery or if user deletes any video then It should get downloaded again.
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.
Hi!
I have some videos that were recorded in portait mode, and when playing in other players it shows the whole video with blank spaces on each side. Can I play the videos without cropping them?
Thanks!
I am searching auto play property of the videoview, But not find anything. Can you guide me. Where you wrote auto play properties of video view
Hi I am relatively new to android, and was trying to implement this inside a fragment. From my novice analysis, it seems that the recyclerview directly works on an Activity. Any chance I can get this working in a fragment?
Thanks!
I'm developing an app that needs to stream videos with the .m3u8 extension. It works with with the ExoPlayer but I couldn't find any reliable library that does that in a RecyclerView like AutoplayVideos does with the ExoPlayer.
Does this library supports this kind of extension?
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)
`./gradlew :autoplay:lint fails with the following error
NewApi: Calling new methods on older versions
../../src/main/java/com/allattentionhere/autoplayvideos/AAH_VideoImage.java:33: Call requires API level 21 (current min is 16): new android.widget.FrameLayout
``` ```
30 }
31
32 public AAH_VideoImage(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
33 super(context, attrs, defStyleAttr, defStyleRes);
34 init();
35 }
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);
While plaplayAvailableVideos(0) called from onDraw(), it crashses app.
I'm loading images and videos from firebase storage via their download url in the database, will this library work with FRA? I see where you state that the adapter should extend AAH_VideoAdapter but I'm not sure if that can be done with the FRA.
I've tried setting it up like you have done, with the only difference being that the adapter doesn't extend AAH_VideoAdapter. So I'm guessing that's why nothing is being displayed.
I get these errors for each item in the adapter:
08-30 20:50:28.959 14942-14942/com.pictematic W/System.err: java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.Object java.util.concurrent.Callable.call()' on a null object reference 08-30 20:50:28.960 14942-14942/com.pictematic W/System.err: at com.allattentionhere.autoplayvideos.AAH_CustomVideoView.onDetachedFromWindow(AAH_CustomVideoView.java:155) 08-30 20:50:28.960 14942-14942/com.pictematic W/System.err: at android.view.View.dispatchDetachedFromWindow(View.java:15564) 08-30 20:50:28.960 14942-14942/com.pictematic W/System.err: at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3179) 08-30 20:50:28.960 14942-14942/com.pictematic W/System.err: at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3179) 08-30 20:50:28.960 14942-14942/com.pictematic W/System.err: at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3179) 08-30 20:50:28.960 14942-14942/com.pictematic W/System.err: at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3179) 08-30 20:50:28.960 14942-14942/com.pictematic W/System.err: at android.view.ViewGroup.removeViewInternal(ViewGroup.java:4715) 08-30 20:50:28.960 14942-14942/com.pictematic W/System.err: at android.view.ViewGroup.removeViewAt(ViewGroup.java:4665) 08-30 20:50:28.960 14942-14942/com.pictematic W/System.err: at android.support.v7.widget.RecyclerView$5.removeViewAt(RecyclerView.java:772) 08-30 20:50:28.961 14942-14942/com.pictematic W/System.err: at android.support.v7.widget.ChildHelper.removeViewAt(ChildHelper.java:168) 08-30 20:50:28.961 14942-14942/com.pictematic W/System.err: at android.support.v7.widget.RecyclerView$LayoutManager.removeViewAt(RecyclerView.java:8035) 08-30 20:50:28.961 14942-14942/com.pictematic W/System.err: at android.support.v7.widget.RecyclerView$LayoutManager.removeAndRecycleViewAt(RecyclerView.java:8307) 08-30 20:50:28.961 14942-14942/com.pictematic W/System.err: at android.support.v7.widget.LinearLayoutManager.recycleChildren(LinearLayoutManager.java:1372) 08-30 20:50:28.961 14942-14942/com.pictematic W/System.err: at android.support.v7.widget.LinearLayoutManager.recycleViewsFromEnd(LinearLayoutManager.java:1458) 08-30 20:50:28.961 14942-14942/com.pictematic W/System.err: at android.support.v7.widget.LinearLayoutManager.recycleByLayoutState(LinearLayoutManager.java:1481) 08-30 20:50:28.961 14942-14942/com.pictematic W/System.err: at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1507) 08-30 20:50:28.961 14942-14942/com.pictematic W/System.err: at android.support.v7.widget.LinearLayoutManager.scrollBy(LinearLayoutManager.java:1330) 08-30 20:50:28.961 14942-14942/com.pictematic W/System.err: at android.support.v7.widget.LinearLayoutManager.scrollVerticallyBy(LinearLayoutManager.java:1074) 08-30 20:50:28.961 14942-14942/com.pictematic W/System.err: at android.support.v7.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:4838) 08-30 20:50:28.961 14942-14942/com.pictematic W/System.err: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874) 08-30 20:50:28.961 14942-14942/com.pictematic W/System.err: at android.view.Choreographer.doCallbacks(Choreographer.java:686) 08-30 20:50:28.961 14942-14942/com.pictematic W/System.err: at android.view.Choreographer.doFrame(Choreographer.java:618) 08-30 20:50:28.962 14942-14942/com.pictematic W/System.err: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860) 08-30 20:50:28.962 14942-14942/com.pictematic W/System.err: at android.os.Handler.handleCallback(Handler.java:751) 08-30 20:50:28.962 14942-14942/com.pictematic W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95) 08-30 20:50:28.962 14942-14942/com.pictematic W/System.err: at android.os.Looper.loop(Looper.java:154) 08-30 20:50:28.962 14942-14942/com.pictematic W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6236) 08-30 20:50:28.962 14942-14942/com.pictematic W/System.err: at java.lang.reflect.Method.invoke(Native Method) 08-30 20:50:28.962 14942-14942/com.pictematic W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:891) 08-30 20:50:28.962 14942-14942/com.pictematic W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:781)
Any ideas on how to fix this?
Hi Krupen,
Video not play automatically and manually, I have the API that contain first 4 pages only image after that one video is come that video not play automatically and click play button also.
this.getSurfaceTexture() is return null
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.