[Q] Play Video From Raw Folder - Android Software Development

Heya,
I've just started programming with android and made a few programs and everything so I'm still kind of a novice but im trying to understand it all.
So here's my problem, I'm trying to play a video, the thing is, I got it working when I Stream it from an URL with VideoView over the internet or when i place in on my sdcard.
What I want to do now is play a video I've got in my res/raw folder, but it only plays audio and I don't understand why, it doesn't give any error in my logcat as far as I can see, also couldn't really find a solution with google since most of the answers are about VideoView and just put the video on your SDCard.
Now someone told me I had to use setDisplay (SurfaceHolder) and I've also tried that but I still only get the audio.
I hope someone can help me find a solution.
Code:
PHP:
package nl.melvin.videodemo;
import android.app.Activity;
import android.os.Bundle;
import android.media.MediaPlayer;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
public class videodemo extends Activity {
public SurfaceHolder holder;
public SurfaceView surfaceView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MediaPlayer mp = MediaPlayer.create(this, R.raw.mac);
mp.setDisplay(holder);
mp.start();
}
}
XML:
PHP:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<SurfaceView
android:id="@+id/surfaceview"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</SurfaceView>>
</LinearLayout>

Does nobody have a solution to this problem, or is it maybe possible that when you download the app from the market the video copys itself to the memory or sdcard so I can use VideoView?
The Android App CPR Choking has this feature of playing a video when you download it.
AppBrain link

Maybe there is a solution in 2011.
Bump~

Related

BufferedInputStream, BufferedInputStream available

Good day, I have a problem with BufferedInputStream.
Code:
String url = "some path";
URL feedUrl = new URL(url);
inputStream = feedUrl.openStream();
BufferedInputStream buffer = new BufferedInputStream(inputStream);
Log.v("buffer.available", String.valueOf(buffer.available()));
why I always have a buffer size 2KB ?
It's the default buffer size. Use the constructor that you can specify buffer size if you want something bigger.
stacktrace said:
It's the default buffer size. Use the constructor that you can specify buffer size if you want something bigger.
Click to expand...
Click to collapse
I think den_4ik asked about why there is always 2KB, even if there should be e.g. 20KB of data.
public synchronized int available() throws IOException
Returns an estimate of the number of bytes (...)
Click to expand...
Click to collapse
You can't know how much data is still there - it's stream, you know. If you really need data size, then you could load it into some memory buffer. Also for some streams you could "guess" its size, e.g.: you could check file size for FileInputStream or if you are fetching data through HTTP protocol, then you could read its length from HTTP headers, etc.
increase buffer size
i want to increase the buffer size/time for streaming live audio
is it an app specific setting, ie., on each radio streaming app?
or is it a media player setting?
i know how to mod an apk
i just need to know where in an app, or music.apk for instance, the value would be set for how long or how much a stream will be buffered
i want to increase it enormously, sick of dropping audio while in a moving car
my theory is that if the buffer was bigger/longer, i wouldnt notice the drop out as often
i have searched
i have not found the answer
started a thread:
http://forum.xda-developers.com/showthread.php?t=722729

[Q] Default media player

Hello everyone,
i'm trying to do a podcast software, but i can't find a way to play music througth the default media player.
What should i use?
I use now Mediaplayer() but it has no user interface (no pause, forward ...) which is pretty annoying.
Thank you for your answers!
Have you looked at the MediaController class:
http://developer.android.com/reference/android/widget/MediaController.html
By now, i used another method with Intent.
String path = "/sdcard/feed/"+ title+"/"+fileName + ".mp3";
Intent myIntent =new Intent(android.content.Intent.ACTION_VIEW);
myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
myIntent.setDataAndType(Uri.parse("file://"+ path),"audio/*");
startActivity(myIntent);
Which actually works for mp3s.
I am looking for the basic Android downloader (the one used by the market for example)
Do you know how to use it?
Thank you a lot
So you want to download the file first to the sdcard, then play it by launching the default program for MIME type "audio/*"? seems convoluted. The MediaPlayer object will do all this for you in streaming mode and the MediaController class will give you a nice interface.
Otherwise, I don't know what you mean by "basic Android downloader".

[Q] Hello, I have an issue with the media player on rotation

I have a media file playing in the oncreate, and everytime i switch over to landscape it replays the audio file, i cannot restrict it from turning to land scape because thats the purpose of the app, is there any way i can possible pause the player and start it up again once its on landscape?
i tried
if(alert.isPlaying() == true){
alert.stop;
}else{
alert.start;
}
Click to expand...
Click to collapse
I just typed this out in this post so i know i made an error, im still new to android programming.
Please and thank you,
Alexander Napoles
Take a look at this.
You could also save if it has already been played in a variable.
Or make an extra class, maybe as activity to play to play the audio file. Use an addiotinaly variable to procted the class from being created twice, because we only want to play it once.
This should keep running in the background and not start again when going landscape mode because it is not part of the activity that is getting recreated when you switch your gui to landscape.
Thank you "Clicks Thanks button" Im going to be testing this out tomorrow morning.

how do i launch music player with a particular song / album?

i thought it may be with an intent but can't find anything, nor can i find anything in the mediaplayer class, but what do i have to do to trigger the stock music player and do i have to pass in a filename as the param?
mhh, something like:
Code:
Uri data = Uri.parse("file://" + mf1.getFilename());
MediaPlayer mp = android.media.MediaPlayer.create(this, data);
mp.start();
will only trigger it as a background process, not switch to it. and an intent view seems to launch a mini player inside the app, so how do i switch to the music player?
http://forum.xda-developers.com/showpost.php?p=13036528&postcount=4
Note: TouchWiz has it's own DB for music for Samsung phones, so you know, we hate them (and the second method may/maynot work on TouchWiz phones).
thanks, i need to get my head around querying the content provider now!

[Q] audio recording issue...

Hi all i'm developing an app for audio recording.
So i used the MediaRecorder class to record. Unfortunately this class hasn't got the pause method so i can just start or stop.
How can i pause the recorder?
For example i'd like to do something like this:
press rec button to start recording
press pause button
press rec button to continue recording...
press stop to save and exit.
ps: I'd like to save the output file as amr or 3gp.
Any idea?
Up
Sent from my HTC HD2 using XDA App
it doesnt appear to be possible with the api's provided by the MediaRecorder class. the way you would have to do it with a MediaRecorder is to record multiple files and then merge them into one audio file. i was thinking that you could append to the file using a file descriptor but then i realized that its not just a plain text file. its an audio file with headers and a complex compressed format and just appending another audio file on the end would do nothing. here are some links
http://stackoverflow.com/questions/5190967/how-to-pause-capturing-video-in-android
http://stackoverflow.com/questions/5743165/pause-and-resume-audio-recording-in-android
http://www.benmccann.com/dev-blog/android-audio-recording-tutorial/
this is a tough one.
ps: I'd like to save the output file as amr or 3gp.
Click to expand...
Click to collapse
this one isnt... =)
setOutputFormat(int outPutFormat);
where outPutFormat can be these values:
---------------------------------------------
int AMR_NB AMR NB file format
int AMR_WB AMR WB file format
int DEFAULT
int MPEG_4 MPEG4 media file format
int RAW_AMR AMR NB file format
int THREE_GPP 3GPP media file format

Categories

Resources