Media Player callbacks only function for an Activity?

by Paper Coder » Mon, 02 Mar 2009 00:45:14 GMT


Sponsored Links
 So if I load a large sound from a resource, is there any way to tell if it's
ready to play?  I wish there was an isPrepared method for media player.  As
it stands now there seems like there's no way to know for sure.










Media Player callbacks only function for an Activity?

by Marco Nelissen » Mon, 02 Mar 2009 01:04:03 GMT


 


Of course there is: prepare() and MediaPlayer.create() are
synchronous, so when those return your MediaPlayer is ready to play.
If you're using prepareAsync(), then you should set an
onPreparedListener before calling prepareAsync, and that listener will
be called when the MediaPlayer is ready for playback.

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


Sponsored Links


Media Player callbacks only function for an Activity?

by Paper Coder » Mon, 02 Mar 2009 08:55:52 GMT


 I didn't realize it wouldn't return the media player until it was ready to
play.

Now the methods in media player make much more sense.  I was wondering why
there wasn't a way to create a new media player object with the new keyword,
then set the resource id.

Thanks!







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



Media Player callbacks only function for an Activity?

by Marco Nelissen » Mon, 02 Mar 2009 10:44:33 GMT


 


You can't set the resource id directly, but you can get a
filedescriptor for the resource. Something like:

MediaPlayer mp = new MediaPlayer();
AssetFileDescriptor afd =
getContext().getResources().openRawResource(R.raw.yourmp3resource);
mp.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(),
afd.getLength());
mp.prepare();
mp.start();

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



Media Player callbacks only function for an Activity?

by Paper Coder » Tue, 03 Mar 2009 12:06:26 GMT


 It's good to know this, especially if I encounter other classes that seem to
not be able to access resources easily.  Although, if I encounter that
situation again, it will set off a warning signal that there is probably an
easier way to do it (as in checking for a null reference in media player to
see if it's ready).

Thank again.







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



Other Threads

1. NPAPI support in Android 2.0 SDK WebView

Hi there,

in older android SDK versions it was possible to load custom NPAPI
plugins into the WebView through reading them from assets and writing
them into the filesystem at the apps data directory, for example
something along the lines:

        webview = (WebView)findViewById(R.id.webview);
                        webview.getSettings().setJavaScriptEnabled(true);
                        webview.getSettings().setPluginsEnabled(true);
                        
webview.getSettings().setPluginsPath("/data/data/com.foo.app");
                        webview.setWebViewClient(new NetworkAccess());

in order to have a WebView instance with NPAPI plugin support for
plugins in that directory.

In Android 2.0 SDK this mechanism does not seem to work anymore and
the WebSettings.setPluginsPath() method seems to be deprecated:
http://developer.android.com/reference/android/webkit/WebSettings.html#setPluginsPath(java.lang.String).

Can anyone confirm this is a final decision or just a bug? Are custom
NPAPI plugins aren't going to be supported in the future anymore?
Would be a shame if that'll be the case ;(

Kind regards,
Anselm

-- 

2. conf file

Hi,

I am writing a module that will print out the parameters of system
calls. I want to do this for different system calls.

Is it possible to write a config file to generalise the process? I
tried searching the net but couldn't find any reference on doing such
a thing.

Thanks in Advance,
Perumal

3. Nexus One - Please make available as DEV phone, so non US dev's can buy/support apps

4. Nexus One - Please make available as DEV phone, so non US dev's can buy/support apps

5. OOT: Clear coat by showcase fever

6. No stats? 0 total; 0 active installs while 5000 AdMob impressions??

7. trivia: the name motorola 'DROID'