launching m3u playlist with intent

by Seb » Sun, 16 Aug 2009 21:11:31 GMT


Sponsored Links
 Hi,

Is there a way to launch a playlist whith intent?

I can retrieve the path of the m3u playlist with:
Cursor cursor = context.getContentResolver().query
(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, null, null, null,
null);
cursor.getString(cursor.getColumnIndex
(MediaStore.Audio.Playlists.DATA));

But, I can't launch this m3u file neither with Intent nor with
MediaPlayer.

Is there a way to do this?

Thanks in advance


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



launching m3u playlist with intent

by Marco Nelissen » Mon, 17 Aug 2009 03:23:56 GMT


 


No.


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


Sponsored Links


launching m3u playlist with intent

by Marco Nelissen » Mon, 17 Aug 2009 03:30:16 GMT


 Well, OK, that's not entirely true. While you can't play an arbitrary
m3u file, you can play playlists that are in the database (which may
have come from m3u files originally, in which case there path is in
the _data column).
To see how, you can look at what happens when you put a shortcut to a
playlist on the home screen and then launch it.







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



launching m3u playlist with intent

by Seb » Mon, 17 Aug 2009 21:36:13 GMT


 Hi Marco,

Thank you very much for the response. You give me the key to find the
solution.

I had to study the code of PlaylistBrowserActivity to find the
solution.

I give it here if someone else search the solution:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setComponent(new ComponentName
("com.android.music","com.android.music.PlaylistBrowserActivity"));
intent.setType(MediaStore.Audio.Playlists.CONTENT_TYPE);
intent.setFlags(0x10000000);
intent.putExtra("oneshot", false);
intent.putExtra("playlist", playlistid);
startActivity(intent);

and to retrieve the playlistid:
Cursor cursor = getContentResolver().query
(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, null, null, null,
null);
if (cursor != null) {
 if (cursor.moveToFirst()) {
  do {
     playlistid = cursor.getString(cursor.getColumnIndex
(MediaStore.Audio.Playlists._ID));
     playList.add(playlist);
     } while (cursor.moveToNext());
     cursor.close();
 }
}







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



launching m3u playlist with intent

by hav...@gmail.com » Fri, 11 Sep 2009 16:12:32 GMT


 Awesome. I love you! :)
This was just what I was looking for.







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



Other Threads

1. sony xperia x10, power button not working for my apps

Hi all,

I develop a application, from application, if you press the power
button to lock, and then unlock it, it will ask for password, it is
working in HTC desire, motorola, but not working in Sony Ericsson
Xperia 10.


Have any one any openion on this, whether any setting is required or
the power button pressed in Xperia is different behaviour than other
device.


--RKJ

-- 

2. Sending GPS location changes in the code

Hello.
I wrote small service listening for GPS device messages.
I wrote also ServiceTestCase planning to check that my service returns
correct longitude and latitude when location is changed.
Unfortunately, onLocationChanged is not called not in the service
under the test nor in the test case.
Should it work?
If yes, what's wrong with my test case?
Thanks in advance.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

package com.gkatz.android.mtg.test;

import java.util.List;

import com.gkatz.android.mtg.LocationService;
import com.gkatz.android.mtg.LocationService.LocationBinder;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.location.LocationProvider;
import android.os.Bundle;
import android.os.IBinder;
import android.os.SystemClock;
import android.test.ServiceTestCase;

public class LocationServiceTest extends
ServiceTestCase<LocationService> implements LocationListener{

        public LocationServiceTest() {
                super(LocationService.class);
                // TODO Auto-generated constructor stub
        }

        @Override
        protected void setUp() throws Exception {
                // TODO Auto-generated method stub
                super.setUp();
        }

        public void testBinding(){
        IBinder locationBinder;

        locationBinder = getServiceBinder();
                assertNotNull(locationBinder);
        }

        public void testStart(){
        Intent locationIntent = new Intent(getContext(),
LocationService.class);

        startService(locationIntent);
        }

        public void testLocationUpdate() throws InterruptedException{

                LocationBinder locationBinder;
                LocationService locationService;
                Context context = getContext();

                LocationManager lm = getLocationManager();

                context.registerReceiver(locationReceiver,
                        new
IntentFilter("android.mtg.custom.intent.action.GPS_LOCATION"));

        locationBinder = (LocationBinder)getServiceBinder();
                assertNotNull(locationBinder);

                locationService = getService();
                assertNotNull(locationService);

                Location loc = new Location(LocationManager.GPS_PROVIDER);
                loc.setLongitude(4.890935);
                loc.setLatitude(52.373801);
                loc.setTime(System.currentTimeMillis());

                lm.setTestProviderLocation(LocationManager.GPS_PROVIDER, loc);

                SystemClock.sleep(3000);

                loc.setLongitude(35.2276757);
                loc.setLatitude(31.7765488);
                loc.setTime(System.currentTimeMillis());

                lm.setTestProviderLocation(LocationManager.GPS_PROVIDER, loc);

                synchronized (this) {
                        this.wait(2000);
                }

                Location lastLoc =
lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
                System.out.println("Last known longitude: " +
Double.toString(lastLoc.getLongitude()) +
                                                   "Last known latitude: " +
Double.toString(lastLoc.getLatitude()));
                assertEquals(35.2276757, locationService.getLongitude());
                assertEquals(31.7765488, locationService.getLatitude());

                context.unregisterReceiver(locationReceiver);
                lm.removeTestProvider(LocationManager.GPS_PROVIDER);
        }
    private BroadcastReceiver locationReceiver=new BroadcastReceiver()
{
                public void onReceive(Context context, Intent intent) {
        
assertTrue(intent.getAction().equals("android.mtg.custom.intent.action.GPS_LOCATION"));
                        System.out.println("Action received: " + 
intent.getAction());
                        this.notify();
                }
    };

    private IBinder getServiceBinder(){
        Intent locationIntent = new Intent(getContext(),
LocationService.class);
        return bindService(locationIntent);
    }

    private LocationManager getLocationManager(){
                LocationManager lm = (LocationManager)
                getContext().getSystemService(Context.LOCATION_SERVICE);

                lm.addTestProvider(LocationManager.GPS_PROVIDER,
                                                   true, true, true, true, 
true, true, true,
                                                   Criteria.POWER_LOW, 
Criteria.ACCURACY_FINE);

                lm.setTestProviderStatus(LocationManager.GPS_PROVIDER,
                LocationProvider.AVAILABLE, null, System.currentTimeMillis());
                lm.setTestProviderEnabled(LocationManager.GPS_PROVIDER, true);
                
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,this);
                return lm;
    }

        @Override
        public void onLocationChanged(Location location) {
                // TODO Auto-generated method stub
                System.out.println("LocationServiceTest, onLocationChanged, 
lon:" +
                                Double.toString(location.getLongitude()) + ", 
lat:" +
                                Double.toString(location.getLatitude()));
        }

        @Override
        public void onProviderDisabled(String provider) {
                // TODO Auto-generated method stub

        }

        @Override
        public void onProviderEnabled(String provider) {
                // TODO Auto-generated method stub

        }

        @Override
        public void onStatusChanged(String provider, int status, Bundle
extras) {
                // TODO Auto-generated method stub

        }
}

-- 

3. Cant refresh listview when I open activity

4. ArrayList for Views/Layouts problem.

5. Accessing raw (uncompressed) image data from the camera via takePicture(...) callbacks impossible

6. Debugging NDK

7. ScreenShotActivity