browsing and playing audio and video files in android - android

I am developing a project in which i need to play Audio and Video files. When audio player is clicked i should display only audio files from sdcard and play those files.
When video player is clicked i only need to display video files and play those video files.
I am using media player for playing the files.
MediaPlayer mp = new MediaPlayer();
String filepath = Environment.getExternalStorageDirectory()+"/f.mp3";
mp.setDataSource(filepath);
mp.start();
But My problem is,how to browse the audio/video files and set the data source dynamically when the user selects a particular file.

You Should use MediaStore which has separate ContentProvider for audio and video
http://developer.android.com/reference/android/provider/MediaStore.html
Audio : http://developer.android.com/reference/android/provider/MediaStore.Audio.html
Video : http://developer.android.com/reference/android/provider/MediaStore.Video.html

Related

How to add my voice with background mp3 music in android?

I am creating an app, which is based on music composition. In this App, a .mp3 song is playing in the background and the user can add their voice with this music and save the recorded music file. I am using media recorder and media player for recording and playing, but my recorded file is not suitable for my app.
The android.media.MediaPlayer class is used to control the audio or video files.
MediaRecorder class can be used to record audio and video files.
You can set output format like this...here 3gp example i am giving you
Mediarecorder recorder;
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);

Multiplexing online audio and video streams in android

There are two media files hosted on external servers - audio and video. I need to mux them and play as online stream through Android MediaPlayer class.
The main problem, is that I don't know, if there is any possible solution for continuous download-mux-play process. I've seen examples of MediaMuxer class usage, but only with local files.
Currently, I just start two media players like this :
//Setting up video
MediaPlayer video = new MediaPlayer();
video.setDataSource("videurl");
video.prepare();
//Setting up audio
MediaPlayer audio = new MediaPlayer();
video.setDataSource("audiourl");
video.prepare();
//Starting both players simultaneously
video.start();
audio.start();
But, of course, this gives terrible synchronization between audio and video. So, the question is - is this even possible to mux online streams, and if yes - where do I start research?

Combining External Audio file to an Existing Video in Android

I want to Record a video On completion of Recording i would like merge an external audio file,finally save it as a video with my Loaded mp3. is it possible in android?

android 2.3 MediaPlayer MPEG AAC Audio

I am trying to play an audio recorded from iPhone in android. The following are the source code the playing the video in android. The extension of the file is MP4.
Uri savedUri = Uri.fromFile(savedUri_file);
MediaPlayer mediaPlayer = MediaPlayer.create(MainActivity.this, getImageUri());
mediaPlayer.start();
The MediaPlayer.create returns a null value. In VLC I have checked the codec information of the audio. It is MPEG AAC Audio (mp4a).
I need to play this in android 2.3. In jelly bean its is working fine. Also I tried with videoview in 2.3, its working. The audio is playing.
Also when I tried play the same file from SD card (by taping on the MP4 file) its played int he default player.
But when I am trying to play the audio created from android device its playing. The codec information of the audion file created from android is AMR Narrow Band (samr).
The following are the code used for creating audio from
NSMutableDictionary *defaultSettings = [[[NSMutableDictionary alloc] init]autorelease];
[defaultSettings setValue :[NSNumber numberWithInt:kAudioFormatMPEG4AAC] forKey:AVFormatIDKey];
[defaultSettings setValue:[NSNumber numberWithFloat:16000.0] forKey:AVSampleRateKey];
[defaultSettings setValue:[NSNumber numberWithInt: 1] forKey:AVNumberOfChannelsKey];
Any hints?

How to play just sound from mp4 file in android?

Can we play just audio from mp4 file ?
I don't want to view video so that i can play mp4 file in background in live wallpaper .
I tried to play mp4 file by using MediaPlayer but sound is not playing .
Any hint ?
check this link it shows something ..
(1). Adding-Background-Music-to-Android-App
(2). play-foreground-and-background-music
and to play audio with video you can go for this ..
(3). how-play-video-and-audio-android

Categories

Resources