亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? musicutils.java

?? Android平臺上的media player, iPhone風格
?? JAVA
?? 第 1 頁 / 共 3 頁
字號:
/* * Copyright (C) 2008 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * *      http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package com.android.imusic;import java.io.File;import java.io.FileDescriptor;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.IOException;import java.io.InputStream;import java.io.OutputStream;import java.util.Arrays;import java.util.Formatter;import java.util.HashMap;import java.util.Locale;import android.app.Activity;import android.app.ExpandableListActivity;import android.content.ComponentName;import android.content.ContentResolver;import android.content.ContentUris;import android.content.ContentValues;import android.content.Context;import android.content.Intent;import android.content.ServiceConnection;import android.content.SharedPreferences;import android.content.SharedPreferences.Editor;import android.content.res.Resources;import android.database.Cursor;import android.graphics.Bitmap;import android.graphics.BitmapFactory;import android.graphics.Canvas;import android.graphics.ColorFilter;import android.graphics.PixelFormat;import android.graphics.drawable.BitmapDrawable;import android.graphics.drawable.Drawable;import android.media.MediaFile;//import android.media.MediaScanner;import android.net.Uri;import android.os.RemoteException;import android.os.Environment;import android.os.ParcelFileDescriptor;import android.provider.MediaStore;import android.provider.Settings;import android.util.Log;import android.view.SubMenu;import android.view.Window;import android.widget.TextView;import android.widget.Toast;public class MusicUtils {    private static final String TAG = "MusicUtils";    public interface Defs {        public final static int OPEN_URL = 0;        public final static int ADD_TO_PLAYLIST = 1;        public final static int USE_AS_RINGTONE = 2;        public final static int PLAYLIST_SELECTED = 3;        public final static int NEW_PLAYLIST = 4;        public final static int PLAY_SELECTION = 5;        public final static int GOTO_START = 6;        public final static int GOTO_PLAYBACK = 7;        public final static int PARTY_SHUFFLE = 8;        public final static int SHUFFLE_ALL = 9;        public final static int DELETE_ITEM = 10;        public final static int SCAN_DONE = 11;        public final static int CHILD_MENU_BASE = 12;        public final static int QUEUE = 13;    }        public static String makeAlbumsSongsLabel(Context context, int numalbums, int numsongs, boolean isUnknown) {        // There are several formats for the albums/songs information:        // "1 Song"   - used if there is only 1 song        // "N Songs" - used for the "unknown artist" item        // "1 Album"/"N Songs"         // "N Album"/"M Songs"        // Depending on locale, these may need to be further subdivided                StringBuilder songs_albums = new StringBuilder();        if (numsongs == 1) {            songs_albums.append(context.getString(R.string.onesong));        } else {            Resources r = context.getResources();            if (! isUnknown) {                String f = r.getQuantityText(R.plurals.Nalbums, numalbums).toString();                sFormatBuilder.setLength(0);                sFormatter.format(f, Integer.valueOf(numalbums));                songs_albums.append(sFormatBuilder);                songs_albums.append(context.getString(R.string.albumsongseparator));            }            String f = r.getQuantityText(R.plurals.Nsongs, numsongs).toString();            sFormatBuilder.setLength(0);            sFormatter.format(f, Integer.valueOf(numsongs));            songs_albums.append(sFormatBuilder);        }        return songs_albums.toString();    }        public static IMediaPlaybackService sService = null;    private static HashMap<Context, ServiceBinder> sConnectionMap = new HashMap<Context, ServiceBinder>();    public static boolean bindToService(Context context) {        return bindToService(context, null);    }    public static boolean bindToService(Context context, ServiceConnection callback) {        context.startService(new Intent(context, MediaPlaybackService.class));        ServiceBinder sb = new ServiceBinder(callback);        sConnectionMap.put(context, sb);        return context.bindService((new Intent()).setClass(context,                MediaPlaybackService.class), sb, 0);    }        public static void unbindFromService(Context context) {        ServiceBinder sb = (ServiceBinder) sConnectionMap.remove(context);        if (sb == null) {            Log.e("MusicUtils", "Trying to unbind for unknown Context");            return;        }        context.unbindService(sb);    }    private static class ServiceBinder implements ServiceConnection {        ServiceConnection mCallback;        ServiceBinder(ServiceConnection callback) {            mCallback = callback;        }                public void onServiceConnected(ComponentName className, android.os.IBinder service) {            sService = IMediaPlaybackService.Stub.asInterface(service);            initAlbumArtCache();            if (mCallback != null) {                mCallback.onServiceConnected(className, service);            }        }                public void onServiceDisconnected(ComponentName className) {            if (mCallback != null) {                mCallback.onServiceDisconnected(className);            }            sService = null;        }    }        public static int getCurrentAlbumId() {        if (sService != null) {            try {                return sService.getAlbumId();            } catch (RemoteException ex) {            }        }        return -1;    }    public static int getCurrentArtistId() {        if (MusicUtils.sService != null) {            try {                return sService.getArtistId();            } catch (RemoteException ex) {            }        }        return -1;    }    public static int getCurrentAudioId() {        if (MusicUtils.sService != null) {            try {                return sService.getAudioId();            } catch (RemoteException ex) {            }        }        return -1;    }        public static int getCurrentShuffleMode() {        int mode = MediaPlaybackService.SHUFFLE_NONE;        if (sService != null) {            try {                mode = sService.getShuffleMode();            } catch (RemoteException ex) {            }        }        return mode;    }        /*     * Returns true if a file is currently opened for playback (regardless     * of whether it's playing or paused).     */    public static boolean isMusicLoaded() {        if (MusicUtils.sService != null) {            try {                return sService.getPath() != null;            } catch (RemoteException ex) {            }        }        return false;    }    private final static int [] sEmptyList = new int[0];        public static int [] getSongListForCursor(Cursor cursor) {        if (cursor == null) {            return sEmptyList;        }        int len = cursor.getCount();        int [] list = new int[len];        cursor.moveToFirst();        int colidx = cursor.getColumnIndex(MediaStore.Audio.Playlists.Members.AUDIO_ID);        if (colidx < 0) {            colidx = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media._ID);        }        for (int i = 0; i < len; i++) {            list[i] = cursor.getInt(colidx);            cursor.moveToNext();        }        return list;    }    public static int [] getSongListForArtist(Context context, int id) {        final String[] ccols = new String[] { MediaStore.Audio.Media._ID };        String where = MediaStore.Audio.Media.ARTIST_ID + "=" + id + " AND " +         MediaStore.Audio.Media.IS_MUSIC + "=1";        Cursor cursor = query(context, MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,                ccols, where, null,                MediaStore.Audio.Media.ALBUM_KEY + ","  + MediaStore.Audio.Media.TRACK);                if (cursor != null) {            int [] list = getSongListForCursor(cursor);            cursor.close();            return list;        }        return sEmptyList;    }    public static int [] getSongListForAlbum(Context context, int id) {        final String[] ccols = new String[] { MediaStore.Audio.Media._ID };        String where = MediaStore.Audio.Media.ALBUM_ID + "=" + id + " AND " +                 MediaStore.Audio.Media.IS_MUSIC + "=1";        Cursor cursor = query(context, MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,                ccols, where, null, MediaStore.Audio.Media.TRACK);        if (cursor != null) {            int [] list = getSongListForCursor(cursor);            cursor.close();            return list;        }        return sEmptyList;    }    public static int [] getSongListForPlaylist(Context context, long plid) {        final String[] ccols = new String[] { MediaStore.Audio.Playlists.Members.AUDIO_ID };        Cursor cursor = query(context, MediaStore.Audio.Playlists.Members.getContentUri("external", plid),                ccols, null, null, MediaStore.Audio.Playlists.Members.DEFAULT_SORT_ORDER);                if (cursor != null) {            int [] list = getSongListForCursor(cursor);            cursor.close();            return list;        }        return sEmptyList;    }        public static void playPlaylist(Context context, long plid) {        int [] list = getSongListForPlaylist(context, plid);        if (list != null) {            playAll(context, list, -1, false);        }    }    public static int [] getAllSongs(Context context) {        Cursor c = query(context, MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,                new String[] {MediaStore.Audio.Media._ID}, MediaStore.Audio.Media.IS_MUSIC + "=1",                null, null);        try {            if (c == null || c.getCount() == 0) {                return null;            }            int len = c.getCount();            int[] list = new int[len];            for (int i = 0; i < len; i++) {                c.moveToNext();                list[i] = c.getInt(0);            }            return list;        } finally {            if (c != null) {                c.close();            }        }    }    /**     * Fills out the given submenu with items for "new playlist" and     * any existing playlists. When the user selects an item, the     * application will receive PLAYLIST_SELECTED with the Uri of     * the selected playlist, NEW_PLAYLIST if a new playlist     * should be created, and QUEUE if the "current playlist" was     * selected.     * @param context The context to use for creating the menu items     * @param sub The submenu to add the items to.     */    public static void makePlaylistMenu(Context context, SubMenu sub) {        String[] cols = new String[] {                MediaStore.Audio.Playlists._ID,                MediaStore.Audio.Playlists.NAME        };        ContentResolver resolver = context.getContentResolver();        if (resolver == null) {            System.out.println("resolver = null");        } else {            String whereclause = MediaStore.Audio.Playlists.NAME + " != ''";            Cursor cur = resolver.query(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,                cols, whereclause, null,                MediaStore.Audio.Playlists.NAME);            sub.clear();            sub.add(1, Defs.QUEUE, 0, R.string.queue);            sub.add(1, Defs.NEW_PLAYLIST, 0, R.string.new_playlist);            if (cur != null && cur.getCount() > 0) {                //sub.addSeparator(1, 0);                cur.moveToFirst();                while (! cur.isAfterLast()) {                    Intent intent = new Intent();                    intent.putExtra("playlist", cur.getInt(0));//                    if (cur.getInt(0) == mLastPlaylistSelected) {//                        sub.add(0, MusicBaseActivity.PLAYLIST_SELECTED, cur.getString(1)).setIntent(intent);//                    } else {                        sub.add(1, Defs.PLAYLIST_SELECTED, 0, cur.getString(1)).setIntent(intent);//                    }                    cur.moveToNext();                }            }            if (cur != null) {                cur.close();            }        }    }    public static void clearPlaylist(Context context, int plid) {        final String[] ccols = new String[] { MediaStore.Audio.Playlists.Members._ID };        Cursor cursor = query(context, MediaStore.Audio.Playlists.Members.getContentUri("external", plid),                ccols, null, null, MediaStore.Audio.Playlists.Members.DEFAULT_SORT_ORDER);                if (cursor == null) {            return;        }        cursor.moveToFirst();//        while (!cursor.isAfterLast()) {//            cursor.deleteRow();//        }//        cursor.commitUpdates();        cursor.close();        return;    }        public static void deleteTracks(Context context, int [] list) {                String [] cols = new String [] { MediaStore.Audio.Media._ID, 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品国产乱码久久久久久久| 欧美日韩五月天| 亚洲国产经典视频| 99久久精品一区| 亚洲电影一区二区| 日韩欧美高清dvd碟片| 久久精品噜噜噜成人av农村| 精品国产乱码久久久久久牛牛| 久久机这里只有精品| 国产日韩欧美a| 色婷婷综合久久久久中文一区二区 | 国产欧美一区二区精品仙草咪| 国产精品一二三区| 亚洲三级免费观看| 91精品国产麻豆| 国产一区二区精品久久| 亚洲欧美自拍偷拍色图| 欧美日韩高清在线| 国产精品自拍av| 亚洲黄色片在线观看| 日韩久久久久久| 成人a区在线观看| 亚洲一区二区三区四区的| 91精品国产欧美一区二区成人| 国产99久久久久久免费看农村| www.欧美色图| 日韩一区二区免费高清| 国产福利精品导航| 一区av在线播放| 26uuu另类欧美亚洲曰本| 99在线精品一区二区三区| 亚洲成人一区二区| 国产欧美日韩视频在线观看| 欧美日韩免费高清一区色橹橹| 另类小说视频一区二区| 亚洲免费在线观看| 欧美精品一区二区久久婷婷| 在线观看网站黄不卡| 精品一区二区三区在线观看 | 五月综合激情网| 国产欧美日韩在线| 91精品国产入口| 91在线视频观看| 国产馆精品极品| 麻豆成人久久精品二区三区红 | 久久久久久夜精品精品免费| 一本久道久久综合中文字幕 | 成人中文字幕合集| 免费三级欧美电影| 亚洲激情男女视频| 国产精品美女久久久久高潮| 日韩午夜精品电影| 欧美三级日本三级少妇99| 91在线精品一区二区三区| 国产一区在线不卡| 日本亚洲三级在线| 亚洲电影你懂得| 亚洲美女免费在线| 国产精品久久久久久久久免费丝袜 | 91小视频免费看| 粉嫩av亚洲一区二区图片| 九色porny丨国产精品| 亚洲chinese男男1069| 日韩一区在线看| 日本一区二区三区国色天香| 精品福利一区二区三区 | 国产一区二区看久久| 另类中文字幕网| 久久66热re国产| 美女mm1313爽爽久久久蜜臀| 日韩av高清在线观看| 亚洲bdsm女犯bdsm网站| 亚洲午夜久久久久久久久久久| 亚洲另类春色校园小说| 亚洲图片你懂的| 国产精品国产三级国产有无不卡| 国产午夜精品理论片a级大结局| 精品国产精品一区二区夜夜嗨| 日韩精品中文字幕在线不卡尤物 | 日本精品视频一区二区三区| 色网站国产精品| 欧美曰成人黄网| 欧美美女喷水视频| 91精品国产综合久久婷婷香蕉| 欧美日韩国产综合草草| 欧美一区二区三区在线观看| 欧美一区二区高清| 久久久美女艺术照精彩视频福利播放| 精品国产乱码久久久久久闺蜜| 337p日本欧洲亚洲大胆精品| 久久久综合视频| 中文字幕日韩欧美一区二区三区| 国产精品久久影院| 亚洲一区自拍偷拍| 视频在线观看国产精品| 狠狠色丁香婷婷综合| 波波电影院一区二区三区| 色综合久久综合| 欧美久久婷婷综合色| 日韩欧美电影一区| 中文字幕一区二区在线播放| 亚洲一区二区三区三| 日本成人中文字幕在线视频| 国产一区二区三区最好精华液| 国产成人亚洲精品狼色在线| 色综合久久久久综合| 欧美一区二区黄| 国产精品高潮呻吟| 天天影视涩香欲综合网| 国产一区二区精品久久91| 一本色道久久综合狠狠躁的推荐| 欧美巨大另类极品videosbest| 国产亚洲成av人在线观看导航 | 国产日韩欧美激情| 亚洲国产毛片aaaaa无费看| 精品写真视频在线观看| 色偷偷88欧美精品久久久| 91精品国产综合久久精品麻豆| 国产亚洲一区二区三区在线观看| 尤物av一区二区| 国产很黄免费观看久久| 欧洲色大大久久| 欧美国产欧美综合| 日本三级亚洲精品| 99久久99久久综合| 日韩亚洲欧美高清| 亚洲精品五月天| 粉嫩13p一区二区三区| 日韩一区二区三区免费看| 亚洲少妇中出一区| 国产自产视频一区二区三区| 欧美亚洲一区二区三区四区| 亚洲国产精品激情在线观看| 免费精品视频最新在线| 日本乱人伦一区| 日本一区二区三区国色天香| 欧美a一区二区| 欧美性生交片4| 中文字幕一区在线观看| 国产精品99久久久久久宅男| 欧美精品久久99| 亚洲一区免费观看| 99久久综合国产精品| 久久久精品中文字幕麻豆发布| 视频一区国产视频| 在线观看成人小视频| 中文字幕亚洲电影| 国产不卡免费视频| 久久精品亚洲麻豆av一区二区 | 欧美国产成人精品| 韩国一区二区三区| 欧美一卡在线观看| 午夜久久电影网| 欧美日韩精品一二三区| 一区二区三区四区五区视频在线观看| 成人精品小蝌蚪| 亚洲国产高清在线| 成人一区二区三区在线观看| 久久网这里都是精品| 国产一区二区三区在线观看免费| 9191国产精品| 全部av―极品视觉盛宴亚洲| 欧美剧情片在线观看| 天天色天天操综合| 51精品视频一区二区三区| 视频一区二区中文字幕| 欧美精选在线播放| 日本v片在线高清不卡在线观看| 欧美日韩国产不卡| 日本欧美久久久久免费播放网| 4hu四虎永久在线影院成人| 日韩二区三区四区| 日韩情涩欧美日韩视频| 久久国产精品免费| 欧美精品一区二区三区蜜臀| 极品美女销魂一区二区三区| 久久久精品国产99久久精品芒果| 国产福利91精品一区二区三区| 国产欧美日韩一区二区三区在线观看 | 国产欧美一区在线| 9人人澡人人爽人人精品| 亚洲激情图片一区| 欧美猛男gaygay网站| 亚洲va国产天堂va久久en| 欧美丰满少妇xxxbbb| 精品一区二区三区不卡 | 国产在线一区观看| 国产精品午夜免费| 91行情网站电视在线观看高清版| 亚洲精品久久7777| 6080日韩午夜伦伦午夜伦| 激情综合色综合久久| 国产精品国产三级国产aⅴ中文| 色88888久久久久久影院按摩| 亚洲成av人片在线| 26uuu精品一区二区在线观看| 成人免费视频播放| 亚洲一区二区欧美日韩| 欧美成人一级视频| av激情成人网|