本文整理汇总了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);
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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);
}
示例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));
}
示例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));
}