当前位置: 首页>>代码示例>>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;未经允许,请勿转载。