Mobile phone audio and video 10-music list, audio and video 10-list

Source: Internet
Author: User

Mobile phone audio and video 10-music list, audio and video 10-list

/*** Get data from local sdcard * // 1. traverse sdcard with the suffix * // 2. obtain the video from the content provider * // 3. if it is a 6.0 system, dynamically obtain the permission to read sdcard */private void getDataFromLocal () {new Thread () {@ Overridepublic void run () {super. run (); // isGrantExternalRW (Activity) context); // SystemClock. sleep (2000); mediaItems = new ArrayList <> (); ContentResolver resolver = context. getContentResolver (); Uri uri = MediaStore. audio. media. EXTERNAL_CONTENT_URI; String [] objs = {MediaStore. audio. media. DISPLAY_NAME, // The name of the video file in the sdcard MediaStore. audio. media. DURATION, // total video DURATION MediaStore. audio. media. SIZE, // the video file SIZE MediaStore. audio. media. DATA, // The absolute video address MediaStore. audio. media. ARTIST, // Song ARTIST}; Cursor cursor = resolver. query (uri, objs, null); if (cursor! = Null) {while (cursor. moveToNext () {MediaItem mediaItem = new MediaItem (); mediaItems. add (mediaItem); // String name = cursor. getString (0); // The video name mediaItem. setName (name); long duration = cursor. getLong (1); // The video length mediaItem. setDuration (duration); long size = cursor. getLong (2); // the video file size mediaItem. setSize (size); String data = cursor. getString (3); // The video playback address mediaItem. setData (data); String artist = cursor. getString (4); // artist mediaItem. setArtist (artist);} cursor. close ();} // Handler sends a message to handler. sendEmptyMessage (10 );}}. start ();}

  

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.