Reputation: 684
i WAnna play a video that is in my assets folder. that can be played in any player installed in android. Help OuT
Upvotes: 2
Views: 1405
Reputation: 1856
check this out :
Intent viewMediaIntent = new Intent();
viewMediaIntent.setAction(android.content.Intent.ACTION_VIEW);
Uri audio = Uri.parse("android.resource://com.audio.test/raw/"+R.raw.audio1);
Log.d(TAG,"uri:"+audio.toString());
viewMediaIntent.setDataAndType(audio, "video/*");
viewMediaIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
Log.d(TAG,"Starting");
Intent i = Intent.createChooser(viewMediaIntent, "Play Music");
mGap.startActivity(i);
Log.d(TAG,"Started");
Upvotes: 1
Reputation: 263
Take a video view and media player in layout and in your activity onCreate you can do this
private VideoView video; private MediaController ctlr; uri=Uri.parse("android.resource://packagename/" + R.raw.famous); video=(VideoView)findViewById(R.id.video); video.setVideoURI(uri); ctlr=new MediaController(this); ctlr.setMediaPlayer(video); video.setMediaController(ctlr); video.requestFocus(); video.start();
Here the video named famous is in raw folder in res. or you can keep in assets and change the file name based on that. Code is tested and it works fine.
Upvotes: 2