eneim / toro

Video list auto playback made simple, specially built for RecyclerView
Apache License 2.0
1.42k stars 253 forks source link

No Video only Black screen with Audio after 2-3 sec #342

Open pankaj-pardhi opened 6 years ago

pankaj-pardhi commented 6 years ago

There is Video Playing, I can see only Black screen and I can able hear only Audio. Help me with this issue

FeedAdapter.class

 public class StoryContentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

    String mUrl = "https://videocdn.bodybuilding.com/video/mp4/62000/62792m.mp4";
    private static final String TAG = StoryContentAdapter.class.getSimpleName();
    private List<StoryDetails> mStoryDetailsList;
    private AppCompatActivity mContext;
    private long mUserId;
    private final int VIDEO = 0;
    private final int POST = 1;
    private int mResourceId;

    public StoryContentAdapter(AppCompatActivity context, int resourceId, long userId, List<StoryDetails> listItems) {
        mContext = context;
        mResourceId = resourceId;
        mUserId = userId;
        mStoryDetailsList = listItems;
    }

    public void setList(ArrayList<StoryDetails> listItems) {
        mStoryDetailsList = listItems;
        notifyDataSetChanged();
        Log.d(TAG, "ItemCount : " + mStoryDetailsList.size());
    }

    @Override
    public int getItemCount() {
        return mStoryDetailsList != null ? mStoryDetailsList.size() : 0;
    }

    @Override
    public int getItemViewType(int position) {
        if (mStoryDetailsList.get(position).getFileType().contains("video")) {
            return VIDEO;
        } else {
            return POST;
        }
    }

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        if (viewType == POST) {
            View itemView = LayoutInflater.from(parent.getContext())
                    .inflate(mResourceId, parent, false);

            return new PostHolder(itemView);
        } else {
            View view = LayoutInflater.from(parent.getContext())
                    .inflate(BasicPlayerViewHolder.LAYOUT_RES, parent, false);

            return new BasicPlayerViewHolder(view);
        }
    }
    @Override
    public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, final int position) {
        if (holder.getItemViewType() == POST) {
            bindPostViewHolder((PostHolder) holder, mStoryDetailsList.get(position));
        } else {
            StoryDetails storyDetails = mStoryDetailsList.get(position);
            Uri uri = Uri.parse(mUrl);
            ((BasicPlayerViewHolder) holder).bind(uri);
        }
    }

    private void bindPostViewHolder(final StoryContentAdapter.PostHolder holder, StoryDetails storyDetails) {
        ImageUtils.loadStoryImageFromUrl(mContext, mUserId, storyDetails.getStoryId(),
                storyDetails.getFileName(), holder.mUserPost);
    }
    public class PostHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.iv_shared_photo)
        ImageView mUserPost;

        public PostHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}

And BasicPlayerViewHolder.class from app folder use provide the code.

Can you please help me with this.

eneim commented 6 years ago

@pankaj-pardhi Try the Url on my Basic demo app and it works well. Can you try your code on Emulator for Pixel 2, running Android 8.1 with Google Store? I want to make sure it is device specific issue or library issue.

pankaj-pardhi commented 6 years ago

It is Working in Demo Code...@Pixel 2...

pankaj-pardhi commented 6 years ago

@eneim

could you suggest the resolution for that

Anything I am missing in code

eneim commented 6 years ago

I wonder if it is an issue of ExoPlayer on Moto G Plus. Can you clone code of ExoPlayer, try their demo app and replace your url their?

pankaj-pardhi commented 6 years ago

@eneim Actually It is showing the same black screen with audio on any device while I am running video in my app

eneim commented 6 years ago

So, does your app runs normally on Pixel 2 emulator? Or it still shows black on Emulator? (your app but not my library’s demo).

Because your link and the ViewHolder works well on my code I need to break down your issue and I want to know if your app has any problem with devices different than Moto G Plus.