1.how to use android_asset
file://android_asset/ is a way that allows android apps access assets by a network-based URI. But assets represent neither local nor online files, they are packed into your apk.Put any files in assets folder in a android project and they will be packed into the apk file by the builder.
2.Sample Code:
mVideoView.setVideoPath("file:///android_asset/videos.mp4");
mVideoView.requestFocus();
mVideoView.start();
String uriPath = "file:///android_asset/videos.mp4";
Uri uri = Uri.parse(uriPath);
mVideoView.setVideoURI(uri);
mVideoView.requestFocus();
mVideoView.start();
String uriPath = "android.resource://yourapplicationpackage/raw/videofilenamewithoutextension";
Uri uri = Uri.parse(uriPath);
video.setVideoURI(uri);
mVideoView.setVideoPath("/mnt/sdcard/android_asset/videos.mp4");
this.setContentView(R.layout.videoview);
mVideoView = (VideoView) this.findViewById(R.id.surface_view);
SurfaceHolder holder = mVideoView.getHolder();
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
MediaPlayer player = new MediaPlayer();
player.setDisplay(holder);
AssetFileDescriptor afd;
try {
afd = getAssets().openFd("v.mp4");
player.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(), afd.getLength());
player.prepareAsync();
player.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.start();
}
});
} catch (Exception e) { e.printStackTrace();}
3.WebView.loadUrl sample code
WebSettings setting=mWebView.getSettings();
setting.setPluginState(PluginState.ON);
setting.setJavaScriptEnabled(true);
String url="file:///android_asset/test.swf";
mWebView.loadUrl(url);
4.Video Resource
Android Application Development:Using the Asset Folder for Typeface
http://v.youku.com/v_show/id_XMzk5NTI4OTA4.html
http://www.youtube.com/watch?v=kOJGmVXuuFA1.how
file://android_asset/ is a way that allows android apps access assets by a network-based URI. But assets represent neither local nor online files, they are packed into your apk.Put any files in assets folder in a android project and they will be packed into the apk file by the builder.
2.Sample Code:
mVideoView.setVideoPath("file:///android_asset/videos.mp4");
mVideoView.requestFocus();
mVideoView.start();
String uriPath = "file:///android_asset/videos.mp4";
Uri uri = Uri.parse(uriPath);
mVideoView.setVideoURI(uri);
mVideoView.requestFocus();
mVideoView.start();
String uriPath = "android.resource://yourapplicationpackage/raw/videofilenamewithoutextension";
Uri uri = Uri.parse(uriPath);
video.setVideoURI(uri);
mVideoView.setVideoPath("/mnt/sdcard/android_asset/videos.mp4");
this.setContentView(R.layout.videoview);
mVideoView = (VideoView) this.findViewById(R.id.surface_view);
SurfaceHolder holder = mVideoView.getHolder();
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
MediaPlayer player = new MediaPlayer();
player.setDisplay(holder);
AssetFileDescriptor afd;
try {
afd = getAssets().openFd("v.mp4");
player.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(), afd.getLength());
player.prepareAsync();
player.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.start();
}
});
} catch (Exception e) { e.printStackTrace();}
3.WebView.loadUrl sample code
WebSettings setting=mWebView.getSettings();
setting.setPluginState(PluginState.ON);
setting.setJavaScriptEnabled(true);
String url="file:///android_asset/test.swf";
mWebView.loadUrl(url);
4.Video Resource
Android Application Development:Using the Asset Folder for Typeface
http://v.youku.com/v_show/id_XMzk5NTI4OTA4.html
http://www.youtube.com/watch?v=kOJGmVXuuFA1.how
0 件のコメント :
コメントを投稿