當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。