yqritc / Android-ScalableVideoView

Android Texture VideoView having a variety of scale types like the scale types of ImageView such as fitCenter, centerCrop, centerTopCrop and more
Apache License 2.0
1.09k stars 223 forks source link

Programitically set width and height of particular video to videoView #10

Closed anvesh523 closed 8 years ago

anvesh523 commented 8 years ago

Right now in sample project FrameLayout height is 300dp. If I changed to match_parent / wrap_content the video is not playing. So, height & width of the video should be set to video view. Can you add this in your library itself or please let me know how can I do my self !

yqritc commented 8 years ago

@anvesh523 If you know the size of video based on item position or view type, then simply set view size in onBindViewHolder like the following.

if (position == 0) {
   holder.mVideoView.getLayoutParams().width = 500;
   holder.mVideoView.getLayoutParams().height = 500;
}

If you dont know the size and wanna use the video size, then u may need to wait for OnPreparedListener callback to get the video size. So do something like the following in onPrepared.

   videoView.getLayoutParams().width = videoView.getVideoWidth();
   videoView.getLayoutParams().height = videoView.getVideoHeight();
   videoView.requestLayout();

However, I believe this is not good practice as an item of recyclerview since u need to wait some time to get the size of video. This causes non-smooth scroll.

anvesh523 commented 8 years ago

Still, thank you for some solution..