当前位置: 首页>>代码示例>>Java>>正文


Java MediaMetadataRetriever.getEmbeddedPicture方法代码示例

本文整理汇总了Java中android.media.MediaMetadataRetriever.getEmbeddedPicture方法的典型用法代码示例。如果您正苦于以下问题:Java MediaMetadataRetriever.getEmbeddedPicture方法的具体用法?Java MediaMetadataRetriever.getEmbeddedPicture怎么用?Java MediaMetadataRetriever.getEmbeddedPicture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.media.MediaMetadataRetriever的用法示例。


在下文中一共展示了MediaMetadataRetriever.getEmbeddedPicture方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAlbumArtFromMP3File

import android.media.MediaMetadataRetriever; //导入方法依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.GINGERBREAD_MR1)
public static Bitmap getAlbumArtFromMP3File(String path) {
    MediaMetadataRetriever mmr = new MediaMetadataRetriever();
    try {
        mmr.setDataSource(path);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
        return null;
    }
    byte[] bytes = mmr.getEmbeddedPicture();
    if (null != bytes) {
        return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
    } else {
        return mmr.getFrameAtTime();
    }
}
 
开发者ID:piyell,项目名称:NeteaseCloudMusic,代码行数:17,代码来源:MP3Util.java

示例2: getMusicThumb

import android.media.MediaMetadataRetriever; //导入方法依赖的package包/类
/**
 * 获取音乐thumb
 *
 * @param filePath 文件路径
 * @return 对应的缩略图
 */
public static Bitmap getMusicThumb(String filePath) {
    Bitmap bitmap = null;

    try {
        MediaMetadataRetriever retriever = new MediaMetadataRetriever();
        retriever.setDataSource(filePath);
        byte[] art = retriever.getEmbeddedPicture();

        if (art != null) {
            bitmap = BitmapFactory.decodeByteArray(art, 0, art.length);
        }
        retriever.release();

        return bitmap;
    } catch (Exception e) {
        if (bitmap != null && !bitmap.isRecycled()) {
            bitmap.recycle();
        }
        System.gc();
        return null;
    } catch (OutOfMemoryError o) {
        System.gc();
        return null;
    }
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:32,代码来源:FeThumbUtils.java

示例3: createAlbumArt

import android.media.MediaMetadataRetriever; //导入方法依赖的package包/类
/**
 * get audio cover
 * @param filePath
 * @return
 */
public static Bitmap createAlbumArt(String filePath) {
    Bitmap bitmap = null;
    //能够获取多媒体文件元数据的类
    MediaMetadataRetriever retriever = new MediaMetadataRetriever();
    try {
        retriever.setDataSource(filePath); //设置数据源
        byte[] bytes = retriever.getEmbeddedPicture(); //得到字节型数据
        if(bytes!=null){
            bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length); //转换为图片
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        try {
            retriever.release();
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }
    return bitmap;
}
 
开发者ID:jiajunhui,项目名称:XDisplay,代码行数:27,代码来源:AudioCoverUtil.java

示例4: createAlbumArt

import android.media.MediaMetadataRetriever; //导入方法依赖的package包/类
/**
 * @Description 获取专辑封面
 * @return 专辑封面bitmap
 */
public static Bitmap createAlbumArt(String path) {
    if (TextUtils.isEmpty(path)) {
        return null;
    }
    Bitmap bitmap = null;
    //能够获取多媒体文件元数据的类
    MediaMetadataRetriever retriever = new MediaMetadataRetriever();
    try {
        retriever.setDataSource(path); //设置数据源
        byte[] embedPic = retriever.getEmbeddedPicture(); //得到字节型数据
        if (embedPic != null) {
            bitmap = BitmapFactory.decodeByteArray(embedPic, 0, embedPic.length); //转换为图片
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        try {
            retriever.release();
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }
    Log.d("zbj1101", "createAlbumArt:bitmap: " + bitmap + ",music: "+path);
    return bitmap;
}
 
开发者ID:fendoudebb,项目名称:PlayAndroid,代码行数:30,代码来源:LocalMusicLibrary.java

示例5: extractAndSetCoverArt

import android.media.MediaMetadataRetriever; //导入方法依赖的package包/类
/**
 * tries to read the cover art from the audio file and sets it as cover art.
 *
 * @param file audio file with potential cover art
 */
private void extractAndSetCoverArt(OCFile file) {
    if (file.isAudio()) {
        try {
            MediaMetadataRetriever mmr = new MediaMetadataRetriever();
            mmr.setDataSource(file.getStoragePath());
            byte[] data = mmr.getEmbeddedPicture();
            if (data != null) {
                Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
                mImagePreview.setImageBitmap(bitmap); //associated cover art in bitmap
            } else {
                mImagePreview.setImageResource(R.drawable.logo);
            }
        } catch (Throwable t) {
            mImagePreview.setImageResource(R.drawable.logo);
        }
    }
}
 
开发者ID:skymania,项目名称:Cirrus,代码行数:23,代码来源:PreviewMediaFragment.java

示例6: loadVideoThumbnail

import android.media.MediaMetadataRetriever; //导入方法依赖的package包/类
/**
 * Loads the thumbnail of a video.
 *
 * @param path The path to the video file.
 * @return {@code null} if the loading failed.
 */
public static Bitmap loadVideoThumbnail(String path) {
    Bitmap bitmap = null;
    MediaMetadataRetriever retriever = new MediaMetadataRetriever();
    try {
        retriever.setDataSource(path);
        byte[] data = retriever.getEmbeddedPicture();
        if (data != null) {
            bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
        }
        if (bitmap == null) {
            bitmap = retriever.getFrameAtTime();
        }
    } catch (IllegalArgumentException e) {
        Log.e(TAG, "MediaMetadataRetriever.setDataSource() fail:" + e.getMessage());
    }
    retriever.release();
    return bitmap;
}
 
开发者ID:jameliu,项目名称:Camera2,代码行数:25,代码来源:LocalDataUtil.java

示例7: doInBackground

import android.media.MediaMetadataRetriever; //导入方法依赖的package包/类
@Override
protected Bitmap doInBackground(Void... v) {
    if (isCancelled() || !isUsing()) {
        return null;
    }
    MediaMetadataRetriever retriever = new MediaMetadataRetriever();
    Bitmap bitmap = null;
    try {
        retriever.setDataSource(mPath);
        byte[] data = retriever.getEmbeddedPicture();
        if (!isCancelled() && isUsing()) {
            if (data != null) {
                bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
            }
            if (bitmap == null) {
                bitmap = retriever.getFrameAtTime();
            }
        }
    } catch (IllegalArgumentException e) {
        Log.e(TAG, "MediaMetadataRetriever.setDataSource() fail:"
                + e.getMessage());
    }
    retriever.release();
    return bitmap;
}
 
开发者ID:asm-products,项目名称:nexus-camera,代码行数:26,代码来源:LocalMediaData.java

示例8: openImageInputStream

import android.media.MediaMetadataRetriever; //导入方法依赖的package包/类
@Override
public InputStream openImageInputStream() {
    if (playable.localFileAvailable()
            && playable.getLocalMediaUrl() != null) {
        MediaMetadataRetriever mmr = new MediaMetadataRetriever();
        try {
            mmr.setDataSource(playable.getLocalMediaUrl());
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
            return null;
        }
        byte[] imgData = mmr.getEmbeddedPicture();
        if (imgData != null) {
            return new PublicByteArrayInputStream(imgData);

        }
    }
    return null;
}
 
开发者ID:danieloeh,项目名称:AntennaPodSP,代码行数:20,代码来源:Playable.java

示例9: loadData

import android.media.MediaMetadataRetriever; //导入方法依赖的package包/类
@Override public InputStream loadData(Priority priority) throws Exception {
	MediaMetadataRetriever retriever = new MediaMetadataRetriever();
	try {
		retriever.setDataSource(model.path);
		byte[] picture = retriever.getEmbeddedPicture();
		if (picture != null) {
			return new ByteArrayInputStream(picture);
		} else {
			return fallback(model.path);
		}
	} finally {
		retriever.release();
	}
}
 
开发者ID:TWiStErRob,项目名称:glide-support,代码行数:15,代码来源:AudioCoverFetcher.java

示例10: loadData

import android.media.MediaMetadataRetriever; //导入方法依赖的package包/类
@Override
public InputStream loadData(Priority priority) throws Exception {
    MediaMetadataRetriever retriever = new MediaMetadataRetriever();
    try {
        retriever.setDataSource(model.filePath);
        byte[] picture = retriever.getEmbeddedPicture();
        if (picture != null) {
            return new ByteArrayInputStream(picture);
        } else {
            return fallback(model.filePath);
        }
    } finally {
        retriever.release();
    }
}
 
开发者ID:aliumujib,项目名称:Orin,代码行数:16,代码来源:AudioFileCoverFetcher.java

示例11: doInBackground

import android.media.MediaMetadataRetriever; //导入方法依赖的package包/类
@Override
protected Void doInBackground(Void... params) {
    Uri u= give.get(p).getSonguri();
    MediaMetadataRetriever m= new MediaMetadataRetriever();
    m.setDataSource(context,u);
    byte[] a = m.getEmbeddedPicture();
    if(a!=null)
    bitmap = BitmapFactory.decodeByteArray(a,0,0);
    return null;
}
 
开发者ID:mdnafiskhan,项目名称:Mp3Player,代码行数:11,代码来源:artistdetailaddapter.java

示例12: parseAlbum

import android.media.MediaMetadataRetriever; //导入方法依赖的package包/类
public static Bitmap parseAlbum(File file) {
    MediaMetadataRetriever metadataRetriever = new MediaMetadataRetriever();
    try {
        metadataRetriever.setDataSource(file.getAbsolutePath());
    } catch (IllegalArgumentException e) {
        Log.e(TAG, "parseAlbum: ", e);
    }
    byte[] albumData = metadataRetriever.getEmbeddedPicture();
    if (albumData != null) {
        return BitmapFactory.decodeByteArray(albumData, 0, albumData.length);
    }
    return null;
}
 
开发者ID:xxczaki,项目名称:music-player,代码行数:14,代码来源:AlbumUtils.java

示例13: getView

import android.media.MediaMetadataRetriever; //导入方法依赖的package包/类
@Override
public View getView(int position, View view, ViewGroup viewGroup) {
    View eltview = view;
    if (view == null) {
        eltview = inflater.inflate(R.layout.playlist_element,null);

        ImageView thumbnail = (ImageView) eltview.findViewById(R.id.thumbnail);
        TextView title = (TextView) eltview.findViewById(R.id.elementTitle);
        TextView artist = (TextView) eltview.findViewById(R.id.elementArtist);

        MediaMetadataRetriever metadataRetriever = new MediaMetadataRetriever();
        metadataRetriever.setDataSource(mData.get(position).get("filepath"));

        try {
            byte[] bytearray = metadataRetriever.getEmbeddedPicture();
            Bitmap albumArt = BitmapFactory.decodeByteArray(bytearray, 0, bytearray.length);
            thumbnail.setImageBitmap(albumArt);
        } catch (Exception e) {
            thumbnail.setImageResource(R.drawable.play);
        }

        title.setText(mData.get(position).get("title"));

        String artistString = "Artist : ";
        if (mData.get(position).get("artist").isEmpty())
            artistString += "Unknown";
        else
            artistString += mData.get(position).get("artist");

        artist.setText(artistString);

    }

    return eltview;
}
 
开发者ID:GaneshPg,项目名称:Musico,代码行数:36,代码来源:AllTracksFragment.java

示例14: doInBackground

import android.media.MediaMetadataRetriever; //导入方法依赖的package包/类
@Override
protected Bitmap doInBackground(VKApiAudio... params) {
    mVkApiAudio = params[0];
    String songUrl = mVkApiAudio.url;

    mediaMetadataRetriever = new MediaMetadataRetriever();
    Bitmap bitmap = null;
    try{
        if (Build.VERSION.SDK_INT >= 14){
            mediaMetadataRetriever.setDataSource(songUrl,
                    new HashMap<String, String>());
        }
        else{
            mediaMetadataRetriever.setDataSource(songUrl);
        }
    }catch (Exception e){
        Log.e(LOG_TAG_GetCoverTask, "getCover() can't set data source: " + songUrl);
        e.printStackTrace();
        mediaMetadataRetriever.release();
        return null;
    }
    byte[] artBytes =  mediaMetadataRetriever.getEmbeddedPicture();
    if(artBytes != null) {
        InputStream is = new ByteArrayInputStream(mediaMetadataRetriever.getEmbeddedPicture());
        bitmap = BitmapFactory.decodeStream(is);
    }

    mediaMetadataRetriever.release();
    return bitmap;
}
 
开发者ID:DmitriyG1,项目名称:vk-music-player-android,代码行数:31,代码来源:VkAudioHelper.java

示例15: showEmbeddedPicture

import android.media.MediaMetadataRetriever; //导入方法依赖的package包/类
@TargetApi( Build.VERSION_CODES.GINGERBREAD_MR1 )
private void showEmbeddedPicture( MediaMetadataRetriever metaData, int viewResourceID ) {
	ImageView view = (ImageView) findViewById( viewResourceID );
	if( view != null ) {
		byte [] rawArtwork = metaData.getEmbeddedPicture();
		if( rawArtwork != null ) {
			Bitmap artwork = BitmapFactory.decodeByteArray( rawArtwork, 0, rawArtwork.length );
			view.setImageBitmap( artwork );
		}
	}
}
 
开发者ID:SilentCircle,项目名称:silent-text-android,代码行数:12,代码来源:MediaPlayerFragmentICS.java


注:本文中的android.media.MediaMetadataRetriever.getEmbeddedPicture方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。