如何从kotlin的道路上获得歌曲的ALBUM ART?

请告诉我如何从媒体文件路径中获取媒体文件的专辑封面。

我已经尝试了下面的代码:


override fun onBindViewHolder(holder: MyViewHolder?, position: Int) { var songObject = items.get(position) retiever.setDataSource(songObject.songData) var art = retiever.embeddedPicture var image = BitmapDrawable(BitmapFactory.decodeByteArray(art,0,art.size)) holder?.art_icon?.setBackgroundDrawable(image) holder?.title?.text = songObject.songTittle holder?.artist?.text = songObject.songArtist holder?.album?.text = songObject.songAlbum SongPlayingManager(items,position,view).check() holder?.complete_song_view?.setOnClickListener { SongPlayingManager(items,position,view).playSong() } } 

此代码不起作用&

LogCat显示以下错误:

进程:com.vikanshu.echo,PID:15640 java.lang.NullPointerException:尝试获取null数组的长度

Kotlin language will be the best programming language for Android.