I don't know how to use the path setDataSource(path) of MediaPlayer?

by dragonksn » Tue, 14 Apr 2009 01:00:02 GMT


Sponsored Links
 Dear all,
I'm a new comer to Android. I want to play a music file located in my
SDCARD image by using my own code. But all the path I have tried with
did not work. The file is located in /myandroid/dcim/Camera/Songs/
track1.mp3 (This seen when I mount the drive to local machine). But
the song can be played by music player of Android.

Can anyone help me with this? I'm very curious with this..

Thanks in advance :)
dragonksn

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. sound in the raw folder

Ok sorry for being so newby, but well i'm a newb.

I'm trying to get sound working for an app i'm working on, i put
my .mp3 file into the resource/raw folder, but for some reason it
doesn't like that, is it because of the format or is it supposed to go
somewhere else, I couldn't seem to find this answer when searching,
but if it's there I'm sorry.

Thanks,
Sean

--~--~---------~--~----~------------~-------~--~----~

2. How to force hierarchy change to PreferenceActivity?

I have a PreferenceActivity building screen hierarchy from code, and I
need to force display hierarchy change dynamically when one of
SharedPreference value changed. I know this might be a kind of easy
quesiton, but I couldn't find answer anywhere in documentations or
discussion.

My PreferenceActivity is forming like this.

-----
public class MyPreferenceActivity extends PreferenceActivity
...
       setPreferenceScreen(createPreferenceHierarchy());
}

private PreferenceScreen createPreferenceHierarchy()
{
        // Root
        PreferenceScreen root = getPreferenceManager
().createPreferenceScreen(this);

        // Orientation tracking smoothing method preference
        PreferenceScreen orientationsmoothingPref = getPreferenceManager
().createPreferenceScreen(this);
        orientationsmoothingPref.setKey( (String) getResources().getText
(R.string.key_screen_orientation_smoothing_method) );
        orientationsmoothingPref.setTitle
(R.string.title_screen_orientation_smoothing_method);
        orientationsmoothingPref.setSummary
(R.string.summary_screen_orientation_smoothing_method);
        root.addPreference(orientationsmoothingPref);

        // List preference
        ListPreference orientationsmoothinglistPref = new ListPreference
(this);
        orientationsmoothinglistPref.setEntries
(R.array.entries_orientation_smoothing_method_preference);
        orientationsmoothinglistPref.setEntryValues
(R.array.entryvalues_orientation_smoothing_method_preference);
        orientationsmoothinglistPref.setKey( (String) getResources().getText
(R.string.key_preference_orientation_smoothing_method) );
        orientationsmoothinglistPref.setTitle
(R.string.title_preference_orientation_smoothing_method);
        orientationsmoothinglistPref.setSummary
(R.string.summary_preference_orientation_smoothing_method);
        orientationsmoothinglistPref.setDefaultValue("No");
        orientationsmoothingPref.addPreference(orientationsmoothinglistPref);

        // Orientation smoothing parameters category
        PreferenceCategory orientationsmoothingparameterPrefCat = new
PreferenceCategory(this);
        orientationsmoothingparameterPrefCat.setTitle
(R.string.title_category_orientation_smoothing_method_parameter);
        orientationsmoothingPref.addPreference
(orientationsmoothingparameterPrefCat);

        String orientationsmoothingmethodStr =
orientationsmoothinglistPref.getValue();

        if ( orientationsmoothingmethodStr.compareTo("no") == 0 )
        {
                /* In case orientation smoothing method is "No" */
                // Nothing to do.
        }
        else if ( orientationsmoothingmethodStr.compareTo("ma") == 0 )
        {
                /* In case orientation smoothing method is "Moving Averaging" */

            // Edit text preference
            EditTextPreference maNPref = new EditTextPreference(this);
            maNPref.setKey( (String) getResources().getText
(R.string.key_preference_ma_n) );
            maNPref.setDialogTitle(R.string.title_preference_ma_n);
            maNPref.setTitle(R.string.title_preference_ma_n);
            maNPref.setSummary(R.string.summary_preference_ma_n);
            maNPref.setDefaultValue("10");
            orientationsmoothingparameterPrefCat.addPreference(maNPref);

        }
        else if ( orientationsmoothingmethodStr.compareTo("ses") == 0 )
        {
                /* In case orientation smoothing method is "Single Exponential
Smoothing" */

            // Edit text preference
            EditTextPreference sesalphaPref = new EditTextPreference(this);
            sesalphaPref.setKey( (String) getResources().getText
(R.string.key_preference_ses_alpha) );
            sesalphaPref.setTitle(R.string.title_preference_ses_alpha);
            sesalphaPref.setDialogTitle(R.string.title_preference_ses_alpha);
            sesalphaPref.setSummary(R.string.summary_preference_ses_alpha);
            sesalphaPref.setDefaultValue("0.3");
            orientationsmoothingparameterPrefCat.addPreference(sesalphaPref);

        }
        else if ( orientationsmoothingmethodStr.compareTo("des") == 0 )
        {
                /* In case orientation smoothing method is "Single Exponential
Smoothing" */

            // Edit text preference
            EditTextPreference desalphaPref = new EditTextPreference(this);
            desalphaPref.setKey( (String) getResources().getText
(R.string.key_preference_des_alpha) );
            desalphaPref.setTitle(R.string.title_preference_des_alpha);
            desalphaPref.setDialogTitle(R.string.title_preference_des_alpha);
            desalphaPref.setSummary(R.string.summary_preference_des_alpha);
            desalphaPref.setDefaultValue("0.3");
            orientationsmoothingparameterPrefCat.addPreference(desalphaPref);

            // Edit text preference
            EditTextPreference desgammaPref = new EditTextPreference(this);
            desgammaPref.setKey( (String) getResources().getText
(R.string.key_preference_des_gamma) );
            desgammaPref.setTitle(R.string.title_preference_des_gamma);
            desgammaPref.setDialogTitle(R.string.title_preference_des_gamma);
            desgammaPref.setSummary(R.string.summary_preference_des_gamma);
            desgammaPref.setDefaultValue("1.0");
            orientationsmoothingparameterPrefCat.addPreference(desgammaPref);

        }

        return root;
}
-----

What I want to do it is everytime ListPreference's value changes,
force redisplay PreferenceScreen. If anyone have any hint, please
reply here. Thanks.

--~--~---------~--~----~------------~-------~--~----~

3. Getting my app in the featured section

4. Understanding MenuCallback code

5. How to customize android by creating a new target product definition

6. Listening to Double Taps in MapView

7. Error when building a custom product with android-sdk-1.5r2