1 year ago
#354588
CHETAN
Unable to view videoview in realtime database using firebase realtime database
I want to view VideoView
in RecyclerView
. I am able to get the Uri of the uploaded videos but I am unable to play that video in the VideoView
. I have checked that the I am getting the correct link of the video.
Here is my adapter code:
class VideoAdapter(private var mContext: Context,private var mvideos: List<VID>) : RecyclerView.Adapter<VideoAdapter.ViewHolder>() {override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {val view = LayoutInflater.from(mContext).inflate(R.layout.videos_adapter, parent, false)return ViewHolder(view)}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val videoid = mvideos[position]
holder.vidId.text = videoid.getilp()
val mediaController = MediaController(mContext)
mediaController.setAnchorView(holder.videoIv)
holder.videoIv.setMediaController(mediaController)
holder.videoIv.setVideoURI(videoid.getVideoUrl().toUri())
holder.videoIv.requestFocus()
holder.videoIv.start()
}
override fun getItemCount(): Int {
return mvideos.size
}
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
var videoIv: VideoView = itemView.videos_ret
var vidId: TextView = itemView.videos_id_ret
}
}
I tried to use this adapter to get videos in VideoView
but it is not playing any video.
android
firebase-realtime-database
android-recyclerview
android-mediaplayer
mediacontroller
0 Answers
Your Answer