Android :: Droid MediaPlayer - Get Correct Duration From Streamed File?
Aug 5, 2010When I stream music using the MediaPlayer, it gives me the wrong song duration. Has anyone else encountered this?
View 2 RepliesWhen I stream music using the MediaPlayer, it gives me the wrong song duration. Has anyone else encountered this?
View 2 RepliesI am having the following problem: I am using Android's MediaPlayer to play an mp3 through an HTTP connection. The audio is played correctly, but the MediaPlayer returns an incorrect duration (calling mediaPlayer.getDuration() ). Depending on the mp3 the duration is either shorter or longer. The code that plays the audio is the following:
mediaPlayer = new MediaPlayer(); mediaPlayer.setOnCompletionListener(this); mediaPlayer.setOnErrorListener(this); mediaPlayer.setOnPreparedListener(this); mediaPlayer.setOnBufferingUpdateListener(this); mediaPlayer.setDataSource("a valid URL"); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mediaPlayer.prepareAsync();............................
For some of the albums/songs it says Unknown Artist but when I look at the files they are all in the proper folders with correct names. I added music using DoubleTwist if that helps.
View 4 Replies View RelatedI want to play a video file sitting in a server by setting local sdp file in the mediaplayer.
How to set the mediaplayer to read the local sdp file and start playing depending on the sdp connect (if it has unicast/multicast, start corresponding session)? I want to test unicast for now.
Could I somehow trick the player on playing something of this format? I know that there is support for AAC encoded files but just how?
View 2 Replies View RelatedRecent news say that flash porting is finished for android and HTC Hero has support for flash. Can I use MediaPlayer API to play flv media file? Is there such documents?
View 3 Replies View RelatedI copied song.mp3 to my project's assets directory and wrote this code:
private MediaPlayer mp;
Uri uri = Uri.parse("file:///android_asset/song.mp3");
mp=MediaPlayer.create(this, uri);
After running the create statement, the variable mp is null.
I have a simple app which needs to display 1 of many text files (DB is no an option currently)
Where is the best place to put this collection of text files? I am guessing "Assets", but am unsure.
I have a requirement to play several sounds many times in my game so instead of creating the MediaPlayer again and again I have called mp.seekTo(0) in onCompletion(mp) so that it will restart. Sometimes the sound is not audible from the device when I call mp.start () after setting mp.seekTo(0); but the player calls onCompletion() without playing any sound, this is observed randomly on most of the sounds
My sounds are of short duration mostly less than a second.
I am using a separate MediaPlayer for each sound (as I need this) -
There are almost 28 sounds in my game so i will be creating 28 MediaPlayers.
Below is the attached code for player
Also If I try to play many sounds one after the other in a short period of time i get an error saying "no more track names available". can u tell Why this is happening...?
check the below code:
CODE:........
This question has been asked [numerous times] before, but I have not seen any definitive answers, or examples of code that actually works. I would like to associate an Activity with a particular file type. For discussion, assume that I want my Activity to be associated with PDFs. Here is what I currently have. I have experimented with many different values and combinations of values in the intent-filter, but I have yet to get my Activity to start when a PDF is selected.
<activity name="com.mycompany.MyActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" />
<data android:mimeType="application/pdf" />
<data android:pathPattern="*.pdf" />
<data android:host="*" />
</intent-filter> </activity>
I've noticed that when using a flashable zip, the files that are copied over retain the same timestamp as the other files in that directory.
I am using the 'package_extract_file' command through the updater-script. Is there a way to change the timestamp on the files that have been copied over to system folders to reflect the correct time/date (through the script)?
I am unable to install the USB drivers for Windows XP - I have downloaded the correct zip file, but the drivers are marked as being detrimental to Windows XP somehow and they just won't install. Can I copy them out of the zip file and manually put them somewhere? I'm inching ever so slowly towards rooting and am trying to get my ducks in line - but they're not cooperating.
View 8 Replies View RelatedWhat is the optimal app for getting streamed video to a Smartphone running android 2.2?
On my PC I use VLC but it seems they don't have any Android app (having donated I'm a tad miffed) so is there anything else out there for generic streaming? I have an app for specific broadcasters but I'd like one that I can pick up streams on my own.
After hearing about the EVO's battery not lasting more than half a day, I was nervous to order the Droid X. I'm seeing some articles online stating that the battery life is pretty decent on the X. How have your experiences been so far? I have mine coming in the mail on Monday, and I'm hoping I don't need an extended battery that will turn my phone into something the size of a cinder block.
View 49 Replies View RelatedI recently switched from the HTC Wing to the Motorola Cliq (love the phone!) but I can't figure out how to listen to music or watch videos streamed from my computer (photos work ok).I was using ORB on my Wing and it worked great.I'm trying to use it on the Cliq but with little to no success (I've also tried using androrb with no luck).
View 1 Replies View Relatedeasiest way to view a call's details, to see call duration? The only way I can find is to go to a contact's info, view call history, then get the details of the call there.
View 6 Replies View RelatedI am trying to play continuous stream using android mediaplayer.but am not able to avoid gap in playback while updating the datasource file of mediaplayer.How can i overcome this problem?
View 1 Replies View RelatedI need to display an alert message for no more than a half a second. As I understand it, Toast only has 2 available durations, with no way to alter them. Correct me if I'm wrong. Which leads me to sing the AlertDialog. What would be the best way of displaying a dialog for 500ms and then dismissing it?
View 4 Replies View RelatedI would get outgoing call duration a call, I thought to get when the persone to the other side answer my call, but with PhoneStateListener we can get the state of a call, but PhoneStateListener changes state to CALL_STATE_OFFHOOK immediately when the outgoing call starts and not when the person to other side answers, so i can't get the effective time of call during a conversation.
View 1 Replies View RelatedGetting reports that mp3 files <= 0.34 secs in length, are not played (or, at least, inaudible) on the Droid X. Works fine on other devices I've tried (e.g. Nexus One, Hero, G1)
All files longer than 0.34 secs are working fine. I've tested this with about 100 files (mixture of short and long) and the correlation is 100%.
I cant find a way to use an url that requires basic auth when im using code...
Anyone that got any ideas?
At the moment I am using this code to inquire google maps for directions from an address to another one, then I simply draw it on a mapview from its GeometryCollection. But yet this isn't enough I need also to extract the total expected duration from the kml. give a little sample code?
code:........................
I want to drop a call after some time duration let me know how to send the event to it or how to throw event on ACTION_DIAL intent
View 2 Replies View RelatedI'm writing an app for Android OS, and I need to store some time values in the SQLite DB. I have been using android.text.format.Time to store the time values in the app, and then inserting the values as millis into the DB as REAL values. On the SDK emulator, everything works perfectly. On the sole phone I've had the opportunity to test my app (so far), my duration code doesn't work as expected. Some relevant code:
private static final String DATABASE_CREATE =
"create table " + DATABASE_TABLE + " ("
+ KEY_ROWID + " integer primary key autoincrement, "
+ KEY_START + " REAL, "
+ KEY_STOP + " REAL, "
+ KEY_DUR + " REAL );";
private SQLiteDatabase mDb;
ContentValues timerValues = new ContentValues();
timerValues.put(KEY_START, stime.toMillis(false));
timerValues.put(KEY_STOP, etime.toMillis(false));
timerValues.put(KEY_DURATION, stime.toMillis(false)-etime.toMillis(false));
int result = mDb.insert(DATABASE_TABLE, null, timerValues);
I pull this data from two separate functions with slightly different bits of code, both using Time.set(long millis), both giving incorrect results: The start and stop values come back correct, but the duration comes out 17 hours too large. Am I missing something about calculating durations or does this just seem like there's something "special" about this particular droid? I'll have another droid to test on Monday, but any ideas are appreciated.
Can anyone tell me if the Android MediaPlayer class is able to play a video stored in a remoted URL? Just for testing purposes, can I use the URL http://localhost/video-name.3gp. Another question is if the MediaPlayer works well on the emulator?
View 2 Replies View RelatedI'm trying to get an ImageView to sit at the bottom of the screen and I have tried every combination I can think of but no matter what I try, it positions itself in the vertical middle, rather than at the bottom.
In my code below, the Text view does sit at the bottom, but the image does not.
What is the correct methodology for adding an element that would align to the bottom of the screen? code...
I am testing the AdMob for Android SDK. I can't set the admob:testing="true" because the admob attribute is unknown.code...
My Eclipse is complaining that admob:testing="true" would have an unknown prefix. Anyone got an idea on how to fix this?
Sub question: Anyone got an idea how to change the height of the ad? It seems to be fixed to 48px, which is not looking good on any DROID phone...
I am working on a application ,where I want to assign a silent ringtone to a particular contact for a duration of time period. Please provide me some suggestion I do not have any idea to implement it.
View 4 Replies View RelatedI need someone to test my First app I did. It is reworked and extended version of Android DatePicker app here: Date Picker | Android Developers. I don't have Android creature, because I am out of the Google test area. My app shows Time Duration using the DatePicker Dialog twice
The result can be seen on the image.
Please email me and I'll attach the tDurator.apk for you. I need feedback about the working state of the app when rotating the Nexus 1 device, but anyone having at least Android system 1.5 (level 3 on the SDK) can run the app. The app is signed for release and in not harm to the phone.
I'm having some trouble accessing attributes like DURATION and DATE_MODIFIED of video and image. My app access these attributes for both type of data but if I take a picture or shoot a video the related attributes are not immediately available through content provider e.g. for DURATION for that specific video it returns 0.
If I restart the phone the attribute for the newly shoot video or picture taken becomes available.
The other way to make the attributes available is to plug in and out your phone to a computer through usb cable. Once that is done the attributes are available.