android - show video Tile in exoplayer -
how can show video tile(thumbnail) instead of it's name in exoplayer?
this code use , , it's result :
public class samplechooseractivity extends activity { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.sample_chooser_activity); listview samplelist = (listview) findviewbyid(r.id.sample_list); final sampleadapter sampleadapter = new sampleadapter(this); sampleadapter.add(new header("local videos")); sampleadapter.addall((object[]) samples.local_videos); samplelist.setadapter(sampleadapter); samplelist.setonitemclicklistener(new onitemclicklistener() { @override public void onitemclick(adapterview<?> parent, view view, int position, long id) { object item = sampleadapter.getitem(position); if (item instanceof samples.sample) { onsampleselected((samples.sample) item); } } }); } private void onsampleselected(samples.sample sample) { intent mpdintent = new intent(this, playeractivity.class) .setdata(uri.parse(sample.uri)) .putextra(playeractivity.content_id_extra, sample.contentid) .putextra(playeractivity.content_type_extra, sample.type) .putextra(playeractivity.provider_extra, sample.provider); startactivity(mpdintent); } private static class sampleadapter extends arrayadapter<object> { public sampleadapter(context context) { super(context, 0); } @override public view getview(int position, view convertview, viewgroup parent) { view view = convertview; if (view == null) { int layoutid = getitemviewtype(position) == 1 ? android.r.layout.simple_list_item_1 : r.layout.sample_chooser_inline_header; view = layoutinflater.from(getcontext()).inflate(layoutid, null, false); } object item = getitem(position); string name = null; if (item instanceof samples.sample) { name = ((samples.sample) item).name; } else if (item instanceof header) { name = ((header) item).name; } ((textview) view).settext(name); return view; } @override public int getitemviewtype(int position) { return (getitem(position) instanceof samples.sample) ? 1 : 0; } @override public int getviewtypecount() { return 2; } } private static class header { public final string name; public header(string name) { this.name = name; } } }
xml file :
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <listview android:id="@+id/sample_list" android:layout_width="match_parent" android:layout_height="match_parent"/> </linearlayout>
as see in image above, video name shown,but want show tile(thumbnail) of video ( screenshot of video) instead of video name,how can ?
edit
used code bitmap thumbnail bitmap null :
string path = "file:///android_asset/video1.mp4"; bitmap thumb = thumbnailutils.createvideothumbnail(path, mediastore.images.thumbnails.mini_kind);
use bellow code create thumbnail video :
bitmap thumb = thumbnailutils.createvideothumbnail(path, mediastore.images.thumbnails.mini_kind);
Comments
Post a Comment