[android-beginners] Re: Having trouble with setDataSource() for MediaPlayer

2010-07-04 Thread appsgrrl
Hi --

I sorted out my problem.  I found the answer in someone's blog.
it turns out that I have to pass the startOffset and the length to the
setDataSource(), and those are obtained via
the AssetFileDescriptor:

AssetFileDescriptor afd = getAssets().openFd(fileName);
mp.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(),
afd.getLength());

That does the trick


On Jun 30, 11:15 pm, appsgrrl bettyoch...@gmail.com wrote:
 I've gotten the MediaPlayer to work with the create() on a resource.
 I'm trying to get it to work with a file in the assets folder.  I've
 tried all sorts of combinations with the setDataSource() method, but I
 keep getting errors.

 Here's one of my error traces:

 E/PlayerDriver(   31): Command PLAYER_SET_DATA_SOURCE completed with
 an error or info PVMFErrNotSupported
 E/MediaPlayer( 1550): error (1, -4)
 E/com.appsgrl.xxx.playerserv...@43d251f0( 1550): IOException on
 setDataSource:Prepare failed.: status=0x1
 W/PlayerDriver(   31): PVMFInfoErrorHandlingComplete
 E/MediaPlayer( 1550): start called in state 0
 E/MediaPlayer( 1550): error (-38, 0)

 I was trying to do the following:  (I did not show the try/catch
 stuff)

          MediaPlayer mp = new MediaPlayer();
          FileDescriptor sfd =
 getAssets().openFd(abc.wav).getFileDescriptor();

          mp.setDataSource(sfd);
          mp.prepare();
          mp.start()

 Does anyone have a simple example of how to play something from the
 asses folder?

 Thanks

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


[android-beginners] Having trouble with setDataSource() for MediaPlayer

2010-07-01 Thread appsgrrl
I've gotten the MediaPlayer to work with the create() on a resource.
I'm trying to get it to work with a file in the assets folder.  I've
tried all sorts of combinations with the setDataSource() method, but I
keep getting errors.

Here's one of my error traces:

E/PlayerDriver(   31): Command PLAYER_SET_DATA_SOURCE completed with
an error or info PVMFErrNotSupported
E/MediaPlayer( 1550): error (1, -4)
E/com.appsgrl.xxx.playerserv...@43d251f0( 1550): IOException on
setDataSource:Prepare failed.: status=0x1
W/PlayerDriver(   31): PVMFInfoErrorHandlingComplete
E/MediaPlayer( 1550): start called in state 0
E/MediaPlayer( 1550): error (-38, 0)

I was trying to do the following:  (I did not show the try/catch
stuff)

 MediaPlayer mp = new MediaPlayer();
 FileDescriptor sfd =
getAssets().openFd(abc.wav).getFileDescriptor();

 mp.setDataSource(sfd);
 mp.prepare();
 mp.start()

Does anyone have a simple example of how to play something from the
asses folder?

Thanks

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


[android-beginners] Re: onHandleIntent(Intent) method does not get called

2010-06-24 Thread appsgrrl
Hi -- Okay, I got further!  Yay!  It turns out that I also had to call
super.onCreate()  to avoid the null pointer exception.
So, if I call super.onCreate() and super.onStartCommand(),  my
onHandleIntent() does get excecuted.

Now, my new mystery is why my service gets an onDestroy() call right
after it is started.
I return START_STICKY from onStartCommand, but that does not seem to
have an effect.
I guess I need to understand the life cycle stuff a little more.



On Jun 23, 9:05 pm, appsgrrl bettyoch...@gmail.com wrote:
 Hi -- You know, that was one of the first things I had thought of, so
 I put a call to super.onHandleIntent() in my class code.
 However, I got a NullPointerException  from IntentService.onStart(),
 which is called from IntentService.onStartCommand(), which is from my
 class's onStartCommand()

 I tried it again, and played with the arguments to no avail.  I assume
 that I use my incoming arguments and pass them  to the
 super.onStartCommand(), correct?

 Thanks again for your help

 On Jun 23, 7:47 am, Mark Murphy mmur...@commonsware.com wrote:

  On Wed, Jun 23, 2010 at 10:37 AM, appsgrrl bettyoch...@gmail.com wrote:
   Thanks for replying.   I also have a logging printout in the
   onStartCommand() method, and that does show as being called.
   If onStartCommand() is called, doesn't that mean my startService()
   from my Activity has indeed started my IntentService?

  Yes. However, be sure you are chaining to the superclass in
  onStartCommand() -- otherwise, you will block IntentService from
  dispatching your Intent to onHandleIntent() via the background thread.

   Who ultimately calls onHandleIntent()?

  IntentService does.

  --
  Mark Murphy (a Commons 
  Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

  _The Busy Coder's Guide to *Advanced* Android Development_
  Version 1.6 Available!

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


[android-beginners] Re: onHandleIntent(Intent) method does not get called

2010-06-23 Thread appsgrrl
Hi --

Thanks for replying.   I also have a logging printout in the
onStartCommand() method, and that does show as being called.
If onStartCommand() is called, doesn't that mean my startService()
from my Activity has indeed started my IntentService?

Who ultimately calls onHandleIntent()?  That's what I cannot figure
out from the docs.

Betty


On Jun 23, 4:02 am, Mark Murphy mmur...@commonsware.com wrote:
 On Wed, Jun 23, 2010 at 1:03 AM, appsgrrl bettyoch...@gmail.com wrote:
  I'm tryng to get an IntentService to work, and I have extended
  IntentService, and I implemented a onHandletIntent(Intent) method.  I
  put some logging in there, but this method never gets called.

  I must be doing something really dumb, but I don't know what it is.

  Is there something else I need to implement or override, or whatever,
  to make this work?

 No, that's pretty much it. Are you sure whatever is supposed to be
 calling startService() is actually calling startService()?

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

 _The Busy Coder's Guide to *Advanced* Android Development_
 Version 1.6 Available!

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


[android-beginners] Re: onHandleIntent(Intent) method does not get called

2010-06-23 Thread appsgrrl
Hi -- You know, that was one of the first things I had thought of, so
I put a call to super.onHandleIntent() in my class code.
However, I got a NullPointerException  from IntentService.onStart(),
which is called from IntentService.onStartCommand(), which is from my
class's onStartCommand()

I tried it again, and played with the arguments to no avail.  I assume
that I use my incoming arguments and pass them  to the
super.onStartCommand(), correct?

Thanks again for your help




On Jun 23, 7:47 am, Mark Murphy mmur...@commonsware.com wrote:
 On Wed, Jun 23, 2010 at 10:37 AM, appsgrrl bettyoch...@gmail.com wrote:
  Thanks for replying.   I also have a logging printout in the
  onStartCommand() method, and that does show as being called.
  If onStartCommand() is called, doesn't that mean my startService()
  from my Activity has indeed started my IntentService?

 Yes. However, be sure you are chaining to the superclass in
 onStartCommand() -- otherwise, you will block IntentService from
 dispatching your Intent to onHandleIntent() via the background thread.

  Who ultimately calls onHandleIntent()?

 IntentService does.

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

 _The Busy Coder's Guide to *Advanced* Android Development_
 Version 1.6 Available!

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


[android-beginners] onHandleIntent(Intent) method does not get called

2010-06-22 Thread appsgrrl
Hi --

I'm tryng to get an IntentService to work, and I have extended
IntentService, and I implemented a onHandletIntent(Intent) method.  I
put some logging in there, but this method never gets called.

I must be doing something really dumb, but I don't know what it is.

Is there something else I need to implement or override, or whatever,
to make this work?

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


[android-beginners] Re: My first post -- ArrayAdapter question

2010-06-12 Thread appsgrrl
Hi -- thanks for the response.  I don't have any TextView in my
layout, which is why I was confused.  I was trying to get this to
appear as the list for stuff for my spinner, and I ended up using
android.R.layout.simple_spinner_dropdown_item for the resourceID and
that worked, so now I'm trying to understand that a bit more.



On Jun 12, 1:41 am, Yuvi yuvidr...@gmail.com wrote:
 The textViewResourceId is actually the id of a layout (as it says on the
 docs: The resource ID for a layout file containing a TextView to use when
 instantiating views.).
 So you should have a layout with a single TextView and it should work.



 On Sat, Jun 12, 2010 at 7:00 AM, appsgrrl bettyoch...@gmail.com wrote:
  Hi all,  this is my first post, and I'm just starting out, so it will
  probably be stoopid.

  I'm trying to use the ArrayAdatper(Context, int textViewResourceId,
  ListTobjects) constructor.

  What resourceId am I supposed to use for the second parameter?

  I want this to apply this ArrayAdapter to a Spinner, and when I tried
  using the Id of the Spinner,  I got a dump in the log, some of which
  is : android.content.res.Resources$NotFoundException: Resource ID
  #0x7f070001 type #0x12 is not valid

  Thanks

  --
  You received this message because you are subscribed to the Google
  Groups Android Beginners group.

  NEW! Try asking and tagging your question on Stack Overflow at
 http://stackoverflow.com/questions/tagged/android

  To unsubscribe from this group, send email to
  android-beginners+unsubscr...@googlegroups.comandroid-beginners%2bunsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-beginners?hl=en

 --
 YuviDroidhttp://android.yuvalsharon.net

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


[android-beginners] My first post -- ArrayAdapter question

2010-06-11 Thread appsgrrl
Hi all,  this is my first post, and I'm just starting out, so it will
probably be stoopid.

I'm trying to use the ArrayAdatper(Context, int textViewResourceId,
ListTobjects) constructor.

What resourceId am I supposed to use for the second parameter?

I want this to apply this ArrayAdapter to a Spinner, and when I tried
using the Id of the Spinner,  I got a dump in the log, some of which
is : android.content.res.Resources$NotFoundException: Resource ID
#0x7f070001 type #0x12 is not valid

Thanks

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en