Doing something every second

by Rexxars » Mon, 17 Aug 2009 04:29:52 GMT


Sponsored Links
 Hi,

I'm trying to create a remote control for a media player
(communicating with a TCP socket over Wifi).
When it retrieves information about the current song being played, it
gets the current position and total duration of the song.
Obviously, what I want is a MM:SS display of the current position.
What is the best way to achieve this?
I could use a thread which sleeps, but that's not very accurate. What
is the "proper" way of making it update every second?

Thanks in advance!

- Rexxars

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



Doing something every second

by Roman ( T-Mobile USA) » Mon, 17 Aug 2009 13:01:30 GMT


 I assume that you have all the needed information about the streams
which you are going to play which means you have also the length
information of the stream. When you start the stream start also a
timer on your mobile device and run it down. If you pause the stream,
try to retrieve the actual position from your player where the stream
is stopped.

I would avoid sending any information about current  position
information over Wifi because in worse case you won't be accurate. You
should consider that your TCP connection is only from type BEST and
your Wifi channel might get congested).

--
Roman Baumgaertner
Sr. SW Engineer-OSDC
T  Mobile stick together
The views, opinions and statements in this email are those of the
author solely in their individual capacity, and do not necessarily
represent those of T-Mobile USA, Inc.




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


Sponsored Links


Doing something every second

by monsoon » Mon, 17 Aug 2009 20:47:47 GMT


 You could use an:  android.os.CountDownTimer
I found it works pretty much like the Timer class in Swing, if you've
dabbled with that.

Cheers
Steve



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



Other Threads

1. "Unable to look up android.git.kernel.org (port 9418) (Name or service not known)" during sync up

Hi all,

I am not able to sync up because of the following error. Does anyone
else is also getting the below errors now(this error was not there
ysterday when i started sync up. but it came during sync up process.
And now its coming even before the sync starts.)

Initializing project platform/external/strace ...
fatal: Unable to look up android.git.kernel.org (port 9418) (Name or
service not known)
error: Cannot fetch platform/external/strace


mad...@madhav-laptop:~/mydroid$
mad...@madhav-laptop:~/mydroid$ repo sync
fatal: Unable to look up android.git.kernel.org (port 9418) (Name or
service not known)
error: Cannot fetch repo

mad...@madhav-laptop:~/mydroid$ repo sync
fatal: Unable to look up android.git.kernel.org (port 9418) (Name or
service not known)
error: Cannot fetch platform/external/jhead

Thank you
Regards
Madhav

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

2. TextView - line break

Is it possible to make TextView to break words in the middle and then
move to another line, instead moving whole word that doesn't fit to
the new line  ?
I have a  width and number of lines of the TextView and a long string
and want to calculate which portion of the String will fit exactly.
the code is
                TextView vTextShort = (TextView) findViewById
(R.id.story_text_partial);
                int lineHeight = vTextShort.getLineHeight();
                int nmbLines = mesuredHeight / lineHeight;
                Paint mPaint = vTextShort.getPaint();
                String shortTextStr = mStoryText;
                mStoryBreakIdx = 0;
                vTextShort.setLines(nmbLines );
                int breakText = mPaint.breakText(mStoryText.toCharArray(), 0,
mStoryText.length(), mesuredWidth, null);
                mStoryBreakIdx = breakText * nmbLines;
It seems to calculate number of chars accurately but not accounting
for the space that left after word is moved to a new line if it
doesn't fit fully.
And i'm looking on how to either break words in the middle or how
calculate a width of the text that will fit correctly.

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

3. Import java.microedition.*... A solution please...

4. market upload issues

5. Google Docs, again

6. How get multiple phone number which are associated with a single contact.

7. Perf and usability : How to lazy load an image from the web ?