當前位置: 首頁>>代碼示例>>Java>>正文


Java AssetManager.openFd方法代碼示例

本文整理匯總了Java中android.content.res.AssetManager.openFd方法的典型用法代碼示例。如果您正苦於以下問題:Java AssetManager.openFd方法的具體用法?Java AssetManager.openFd怎麽用?Java AssetManager.openFd使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.res.AssetManager的用法示例。


在下文中一共展示了AssetManager.openFd方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: playAsset

import android.content.res.AssetManager; //導入方法依賴的package包/類
private void playAsset(String resName) {
    LogUtil.d(TAG, "playAsset:" + resName);
    try {
        AssetManager am = context.getAssets();
        AssetFileDescriptor afd = am.openFd(resName);
        mMediaPlayer.reset();
        mMediaPlayer.setDataSource(afd.getFileDescriptor(),
                afd.getStartOffset(), afd.getLength());
        mMediaPlayer.prepareAsync();
        mCurrentState = IMediaPlayer.PlayState.PREPARING;
    } catch (IOException e) {
        e.printStackTrace();
        LogUtil.d(TAG, "playAsset", e);
        mCurrentState = IMediaPlayer.PlayState.ERROR;
        fireOnError("IOException play playAsset",
                IMediaPlayer.ErrorType.MEDIA_ERROR_INTERNAL_DEVICE_ERROR);
    }
}
 
開發者ID:dueros,項目名稱:dcs-sdk-java,代碼行數:19,代碼來源:MediaPlayerImpl.java

示例2: onSurfaceCreated

import android.content.res.AssetManager; //導入方法依賴的package包/類
@Override
public void onSurfaceCreated(SurfaceHolder holder) {
    L.d("VideoEngine#onSurfaceCreated ");
    super.onSurfaceCreated(holder);
    mMediaPlayer = new MediaPlayer();
    mMediaPlayer.setSurface(holder.getSurface());
    try {
        AssetManager assetMg = getApplicationContext().getAssets();
        AssetFileDescriptor fileDescriptor = assetMg.openFd("test1.mp4");
        mMediaPlayer.setDataSource(fileDescriptor.getFileDescriptor(),
                fileDescriptor.getStartOffset(), fileDescriptor.getLength());
        mMediaPlayer.setLooping(true);
        mMediaPlayer.setVolume(0, 0);
        mMediaPlayer.prepare();
        mMediaPlayer.start();

    } catch (IOException e) {
        e.printStackTrace();
    }

}
 
開發者ID:WanAndroid,項目名稱:LiveWallPaper,代碼行數:22,代碼來源:VideoLiveWallpaper.java

示例3: initMediaPlayer

import android.content.res.AssetManager; //導入方法依賴的package包/類
private void initMediaPlayer(SurfaceHolder holder){
    mediaPlayer = new MediaPlayer();
    try {
        AssetManager assetMg = getApplicationContext().getAssets();
        AssetFileDescriptor fileDescriptor = assetMg.openFd(此處資源asset請從鴻洋大神那獲取);
        mediaPlayer.setDataSource(fileDescriptor.getFileDescriptor(),
                fileDescriptor.getStartOffset(), fileDescriptor.getLength());
        mediaPlayer.setDisplay(holder);
        mediaPlayer.prepare();
        mediaPlayer.setLooping(true);
        mediaPlayer.setVolume(0, 0);
        mediaPlayer.prepare();
    }catch (Exception e){
        e.printStackTrace();
    }

}
 
開發者ID:WanAndroid,項目名稱:LiveWallPaper,代碼行數:18,代碼來源:DynamicWallPaper.java

示例4: onSurfaceCreated

import android.content.res.AssetManager; //導入方法依賴的package包/類
@Override
public void onSurfaceCreated(SurfaceHolder holder) {
    super.onSurfaceCreated(holder);
    mMediaPlayer = new MediaPlayer();
    mMediaPlayer.setSurface(holder.getSurface());
    try {
        AssetManager assets = getApplicationContext().getAssets();
        AssetFileDescriptor descriptor = assets.openFd("text1.mp4");
        mMediaPlayer.setDataSource(descriptor.getFileDescriptor(),descriptor.getStartOffset(),descriptor.getLength());
        mMediaPlayer.setLooping(true);
        mMediaPlayer.setVolume(1.0f,1.0f);
        mMediaPlayer.prepare();
        mMediaPlayer.start();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
開發者ID:MirDong,項目名稱:VideoWallPager,代碼行數:18,代碼來源:VideoLiveWallPaper.java

示例5: getAssetFileDescription

import android.content.res.AssetManager; //導入方法依賴的package包/類
public static AssetFileDescriptor getAssetFileDescription(String filename) throws IOException {
    AssetManager manager = King.getApplicationContext().getAssets();
    return manager.openFd(filename);
}
 
開發者ID:jiangkang,項目名稱:KTools,代碼行數:5,代碼來源:FileUtils.java

示例6: GifAnimationMetaData

import android.content.res.AssetManager; //導入方法依賴的package包/類
/**
 * Retrieves metadata from asset.
 * 
 * @param assets
 *            AssetManager to read from
 * @param assetName
 *            name of the asset
 * @throws IOException
 *             when opening failed
 * @throws NullPointerException
 *             if assets or assetName is null
 */
public GifAnimationMetaData(AssetManager assets, String assetName)
		throws IOException {
	this(assets.openFd(assetName));
}
 
開發者ID:smartbeng,項目名稱:PaoMovie,代碼行數:17,代碼來源:GifAnimationMetaData.java

示例7: GifDrawable

import android.content.res.AssetManager; //導入方法依賴的package包/類
/**
 * Creates drawable from asset.
 * 
 * @param assets
 *            AssetManager to read from
 * @param assetName
 *            name of the asset
 * @throws IOException
 *             when opening failed
 * @throws NullPointerException
 *             if assets or assetName is null
 */
public GifDrawable(AssetManager assets, String assetName)
		throws IOException {
	this(assets.openFd(assetName));
}
 
開發者ID:smartbeng,項目名稱:PaoMovie,代碼行數:17,代碼來源:GifDrawable.java


注:本文中的android.content.res.AssetManager.openFd方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。