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


Java MediaMetadataRetriever.release方法代码示例

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


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

示例1: parseMP3File

import android.media.MediaMetadataRetriever; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.GINGERBREAD_MR1)
public static MusicBean parseMP3File(String path) {
    MediaMetadataRetriever mmr = new MediaMetadataRetriever();
    String name = null;
    String singer = null;
    String album = null;
    long duration = 0;


    try {
        mmr.setDataSource(path);
        name = mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE);
        singer = mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST);
        album = mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUM);
        duration = Long.valueOf(mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION));
        mmr.release();
    } catch (Exception e) {
        e.printStackTrace();
        return null;

    }
    return new MusicBean(name, singer, album, duration, path);
}
 
开发者ID:piyell,项目名称:NeteaseCloudMusic,代码行数:24,代码来源:MP3Util.java

示例2: getFileMeta

import android.media.MediaMetadataRetriever; //导入方法依赖的package包/类
/**
 * Used to get information about the written file
 */
private void getFileMeta() {

    if (absolutePath != null) {

        try {

            final MediaMetadataRetriever mmr = new MediaMetadataRetriever();
            mmr.setDataSource(absolutePath);
            final String duration = mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
            mmr.release();

            if (DEBUG) {
                MyLog.i(CLS_NAME, "recording duration: " + duration);
            }

        } catch (final RuntimeException e) {
            if (DEBUG) {
                MyLog.w(CLS_NAME, "RuntimeException: completeFileWrite");
                e.printStackTrace();
            }
        }
    }
}
 
开发者ID:brandall76,项目名称:Saiy-PS,代码行数:27,代码来源:FileCreator.java

示例3: getVideoDuration

import android.media.MediaMetadataRetriever; //导入方法依赖的package包/类
/**
 * 从视频文件中读取视频长度
 */
public static long getVideoDuration(Context context, String videoFile) {
    MediaMetadataRetriever retriever = new MediaMetadataRetriever();
    //use one of overloaded setDataSource() functions to set your data source
    String time;
    try {
        retriever.setDataSource(context, Uri.fromFile(new File(videoFile)));
        time = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
        int width = Integer.parseInt(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT));
        int height = Integer.parseInt(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH));
    } finally {
        try {
            retriever.release();
        } catch (Exception ex) {
            // Ignore failures while cleaning up.
        }
    }

    long timeInMillisec = Long.parseLong(time);

    return timeInMillisec;
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:25,代码来源:ImageGridActivity.java

示例4: MoviePlayer

import android.media.MediaMetadataRetriever; //导入方法依赖的package包/类
public MoviePlayer(File sourceFile, Surface outputSurface)
        throws IOException {
    // Pop the file open and pull out the video characteristics.
    // TODO: consider leaving the extractor open.  Should be able to just seek back to
    //       the start after each iteration of play.  Need to rearrange the API a bit --
    //       currently play() is taking an all-in-one open+work+release approach.
    try {
        Log.d(TAG, sourceFile.toString());
        MediaMetadataRetriever retriever = new MediaMetadataRetriever();
        retriever.setDataSource(sourceFile.toString());
        mVideoDuration = Long.valueOf(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION));
        Log.d(TAG, "Duration: " + mVideoDuration);
        retriever.release();

        mVideoDecoder = new VideoDecoder(this, sourceFile);
        mVideoDecoder.setOutputSurface(outputSurface);
        mAudioDecoder = new AudioDecoder(this, sourceFile);
        mVideoDecoder.prepare();
        mAudioDecoder.prepare();
    } catch (Exception ex) {
        release();
        throw new IOException(ex.getMessage());
    }
}
 
开发者ID:Tai-Kimura,项目名称:VideoApplication,代码行数:25,代码来源:MoviePlayer.java

示例5: 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

示例6: 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

示例7: 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

示例8: needToCrop

import android.media.MediaMetadataRetriever; //导入方法依赖的package包/类
public static boolean needToCrop(String originMediaPath) {
  MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
  mediaMetadataRetriever.setDataSource(originMediaPath);
  int videoWidth =
      Integer.parseInt(mediaMetadataRetriever
          .extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH));
  int videoHeight =
      Integer.parseInt(mediaMetadataRetriever
          .extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT));
  int rotation = getRotation(mediaMetadataRetriever);
  mediaMetadataRetriever.release();
  if (rotation == 0 || rotation == 180) {
    return videoHeight != videoWidth * 3 / 4;
  } else if (rotation == 90 || rotation == 270) {
    return videoWidth != videoHeight * 3 / 4;
  }
  return true;
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:19,代码来源:VideoUtils.java

示例9: getVideoCover

import android.media.MediaMetadataRetriever; //导入方法依赖的package包/类
public static String getVideoCover(String videoPath, String coverName) {
  coverName = TextUtils.isEmpty(coverName) ? COVER_NAME : coverName;
  String parentPath = new File(videoPath).getParent();
  String coverPath = parentPath.endsWith(File.separator) ? parentPath
      + coverName : parentPath + File.separator + coverName;
  if (new File(coverPath).isFile()) {
    return coverPath;
  }
  MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
  mediaMetadataRetriever.setDataSource(videoPath);
  Bitmap bitmap = mediaMetadataRetriever.getFrameAtTime(1);
  mediaMetadataRetriever.release();
  if (bitmap != null) {
    return FileUtils.saveBitmapToFile(bitmap, new File(videoPath).getParent(), coverName,
        FILTER_COVER_NAME.equals(coverName) ? 10 : 100);
  }
  return "";
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:19,代码来源:VideoUtils.java

示例10: loadData

import android.media.MediaMetadataRetriever; //导入方法依赖的package包/类
@Override
public InputStream loadData(Priority priority) throws Exception {
    MediaMetadataRetriever retriever = new MediaMetadataRetriever();
    try {
        Log.d("VideoThumbnailFetcher", "model.path= " + model.path);
        retriever.setDataSource(model.path, new HashMap<String, String>());
        Bitmap bitmap = retriever.getFrameAtTime();
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
        byte[] picture = stream.toByteArray();
        if (picture != null) {
            return new ByteArrayInputStream(picture);
        } else {
            return fallback(model.path);
        }
    } finally {
        retriever.release();
    }
}
 
开发者ID:QuickBlox,项目名称:ChatMessagesAdapter-android,代码行数:20,代码来源:VideoThumbnailFetcher.java

示例11: checkIsHaveMetaData

import android.media.MediaMetadataRetriever; //导入方法依赖的package包/类
private boolean checkIsHaveMetaData(Uri fileUri) {
    try {
        MediaMetadataRetriever metadataRetriever = new MediaMetadataRetriever();
        metadataRetriever.setDataSource(this, fileUri);

        contentData = metadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DATE);
        contentLocation = metadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_LOCATION);
        metadataRetriever.release();

        parsMetaLocation();

        SimpleDateFormat metaDateFormat = new SimpleDateFormat(Constants.VIDEO_META_DATE_MASK);
        violationDate = metaDateFormat.parse(contentData);
        return true;

    } catch (Exception e) {
        e.printStackTrace();
        contentNotReady();
        return false;
    }
}
 
开发者ID:stfalcon-studio,项目名称:patrol-android,代码行数:22,代码来源:UploadVideoActivity.java

示例12: verifyLocationInFile

import android.media.MediaMetadataRetriever; //导入方法依赖的package包/类
private void verifyLocationInFile(String fileName) {
    MediaMetadataRetriever retriever = new MediaMetadataRetriever();
    retriever.setDataSource(fileName);
    String location = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_LOCATION);
    assertNotNull("No location information found in file " + fileName, location);
    // parsing String location and recover the location inforamtion in floats
    // Make sure the tolerance is very small - due to rounding errors.
    // Get the position of the -/+ sign in location String, which indicates
    // the beginning of the longtitude.
    int index = location.lastIndexOf('-');
    if (index == -1) {
        index = location.lastIndexOf('+');
    }
    assertTrue("+ or - is not found", index != -1);
    assertTrue("+ or - is only found at the beginning", index != 0);
    float latitude = Float.parseFloat(location.substring(0, index - 1));
    float longitude = Float.parseFloat(location.substring(index));
    assertTrue("Incorrect latitude: " + latitude,
            Math.abs(latitude - LATITUDE) <= TOLERANCE);
    assertTrue("Incorrect longitude: " + longitude,
            Math.abs(longitude - LONGITUDE) <= TOLERANCE);
    retriever.release();
}
 
开发者ID:binkery,项目名称:allinone,代码行数:24,代码来源:MediaMuxerTest.java

示例13: 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

示例14: 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

示例15: getRotation

import android.media.MediaMetadataRetriever; //导入方法依赖的package包/类
public int getRotation()
{
  MediaMetadataRetriever retriever = new MediaMetadataRetriever();
  if (this.path != null)
    retriever.setDataSource(this.path);
  else if (this.fileDescriptor != null)
    retriever.setDataSource(this.fileDescriptor);
  else if (this.uri != null)
    retriever.setDataSource(this.context, android.net.Uri.parse(this.uri.getString()));
  else {
    throw new IllegalStateException("File not set");
  }
  String rotation = retriever.extractMetadata(24);
  retriever.release();
  return Integer.parseInt(rotation);
}
 
开发者ID:jiangerji,项目名称:android-screen-recorder,代码行数:17,代码来源:MediaExtractorPlugin.java


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