The [Android algorithm] is used to obtain the video Thumbnail (thumbnailutils) and play the video.

Source: Internet
Author: User
  • Package com. Test. activity;
  • Import java. Text. decimalformat;
  • Import java. Text. numberformat;
  • Import java. util. List;
  • Import Android. App. activity;
  • Import Android. App. alertdialog;
  • Import Android. content. context;
  • Import Android. content. dialoginterface;
  • Import Android. content. intent;
  • Import Android. Graphics. Bitmap;
  • Import Android. Graphics. drawable. bitmapdrawable;
  • Import Android. Graphics. drawable. drawable;
  • Import android.net. Uri;
  • Import Android. OS. Bundle;
  • Import Android. OS. environment;
  • Import Android. provider. mediastore. Images. thumbnails;
  • Import Android. View. view;
  • Import Android. widget. Button;
  • Import Android. widget. imageview;
  • Import Android. widget. textview;
  • Import Android. Location. criteria;
  • Import Android. Location. location;
  • Import Android. Location. locationlistener;
  • Import Android. Location. locationmanager;
  • Import Android. Media. thumbnailutils;
  • Import com. Google. Android. Maps. geopoint;
  • Import com. Google. Android. Maps. mapactivity;
  • Import com. Google. Android. Maps. mapcontroller;
  • Import com. Google. Android. Maps. mapview;
  • Import com. Google. Android. Maps. overlay;
  • Import com. Google. Android. Maps. overlayitem;
  • Import com. Test. activity. util. helloitemizedoverlay;
  • Import com. Test. activity. util. myoverlay;
  • Public
    Class mainactivity extends activity {
  • @ Override
  • Public
    Void oncreate (bundle savedinstancestate ){
  • Super. oncreate (savedinstancestate );
  • Setcontentview (R. layout. Main );
  •  
    Bitmap
    Bitmap = thumbnailutils. createvideothumbnail (environment. getexternalstoragedirectory () + "/20110.mp4", thumbnails. mini_kind );
  • Bitmap bitmap1 = thumbnailutils. extractthumbnail (bitmap, 200,200 );
  • Bitmapdrawable d = new bitmapdrawable (bitmap1 );
  • (Imageview) findviewbyid (R. Id. imageview). setbackgrounddrawable (d );
  • (Imageview) findviewbyid (R. Id. imageview). setonclicklistener (New View. onclicklistener (){
  • @ Override
  • Public
    Void onclick (view v ){
  • // Todo auto-generated method stub
  • Intent it = new intent (intent. action_view );
  • System. Out. println (environment. getexternalstoragestate (). Equals (environment. media_mounted ));
  • Uri uri = URI. parse (environment. getexternalstoragedirectory () + "/20110.mp4 ");
  • It. setdataandtype (Uri, "Video/MP4 ");
  • Startactivity (it );
  • }
  • });
  • }
  • }

Original http://blog.csdn.net/sun6223508/archive/2011/06/28/6573257.aspx

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.