Ft 6tziuvmimvmT

private void p]aySong(String file) { Log.i("playSong:file); try (

Noti1ication notification = new Notification(); nm.notify(NOTIFY ID, notification);

Log.i("playSong:", "------------------------");

mpr.setDataSonrce(file) ; mpr.prepare() ; mpr.start();

mpr.setOnCompletionListener(new OnCompletionListener() ( public void onCompletion(MediaPlayer argO) ( nextSong() ; )

Log.e (getString(R. string, appnarne) , e.getMessage () ) ; }

//T-i private void nextSong() I

// Check if last song or not if (• icurrent Position > songs.size()) {

current-Position = 0;

nm.cancel(NOTIFY ID);

piaySong(songs.get(currentPosition) ) ; }

if (mpr . getCurrentPosi t.ion () < 3000 && cui rentPos i t ion >= 1) ( playSong(songs.get(--currentPosition)); I else I

playSong(songs.qet(current Position)); ) )

X immft:

I. iX fi'i '<)< m T /& $ W £ S xjj ftg, J( ffii Jj th if ft {]■ /YOBO.Android src/us/imnet/iccskysl/ Service/YPRService.java

3. fflj

/}-: PlayLislActivity W onCreate ^a+ilffi^^SljBiJffi^iaW Service,

I this.bindService(new Intent(PlayListActivity.this,

PRSer vice, class) , mConnection, Context .BIND AUTC_CREATE) ;

<\:X\iMl\M\\>k> ft Activity jfiH ServiceConnection Service IC'P mConnection WaL'XWiiP

I private ServiceConnection mConnection = new ServiceConnection() {

public void onServiceConnected(ComponentName className, IBinder Service) {

mplntertace = YPRSTnterface.Stub.aslnterface((IBinder) Service); updateSongList(); )

public void onServiceDisconnected(ComponentName className) i mplnterface - null; >

M/A^J^AlliKilJ'Rliiii. 1kif)L)± l-JilKm'iJ updateSongList tlfft, W&mmUII b'ffi>}<:

public- void updateSongList () { try {

mplnterface.clearPlaylist(); if (play1i st != null) {

tor (Track track : playlist.getTracks()) I songs.add(track.getTitle() ) ;

mplnteriace.addSongPlaylist (track.get.Lofcation () ) ;

Ltemlist = (List-View) f .. ndViewBy I d (R. id. itemlist) ; ArrayAdapter<Track> adapter = new ArrayAdapter<Track>(this, android.R.layout.simple iist_item_l, playlist .getTracks());

itemlist.setAdapter(adapter); itemlist.setOnltemClickListener(this); itemlist.setSelection(0); i

) catch (RernoteException e> (

Log.e(getString(R.string.app_name), e.getMessage()); }

YPRsimerface

(¿Override public void onltemClick (AdapterView<?> araO, View argl, int. position, long arg3) (

Log. i ("oriList ItemClick: ", Inteqer . toString (position) ) ; try (

player position = position;

mplnterface.playFile (p>osition) ;

itemlist. set Selector (R .color . t ran s lucent. _red> ;

) caten (RernoteException e) I

Log.e (getStrinq(R.string.app_name) , e. getMessage () ); )

(^Override public boolean onCreateOptionsMenu(Menu menu) {

super.onCreateOptionsMenu(menu);

menu.add(0, PLAY NEXT, 0, R.string.player next).setlcon( R.drawable.player_fwd).setAlphabeticShortcut('N'); menu.add(0, PLAYPREV, 0, R.string.player prev).setIcon( R.drawable.player row).setAlphabeticShortcut('P'); menu.add(0, PLAY STOP, 0, R.string.player stop).setlcon( R.drawable.player stop).setAlphabeticShortcut('S'); return true;

(¿Override public boolean onOptionsItemSelected(MenuItem item) ( switch (item.getItemld()) ( case PLAY NEXT : try (

mplnterface.skipForward();

itemlist.setSelector(R.color.translucent red); ) catch (RemoteException e) { e.printStackTrace ( ); I

return true; case PLAY PREV: try {

mplnterface.skipBack();

itemlist.setSelector(R.color.translucent red); ) catch (RemoteException e) ( e.printSt ackTrace (); )

case PLAYSTOP: try (

mplnterface.stop(); } catch (RemoteException e) ( e.printStackTrace();

ùi> «iR^^Mifistfeir. &®ïïimmnmi. Li^^itafcitaffl. n&

f&M YOBO API ïïifrm, mM^mmmrmu mi. sikm^mn u> -%«4'ÎI<]!®CÉ: »una* a«

ïj) ogtÈft wM x ®rmtfiA ni y. /± im «n h m ta s n w & #.

fi « m m « me. «j m n % jn. *e sî s a * & m « & t a» «t -mmw, n n ¡s m * as

god is a girl (album version) I on Best of

fö&ifc» on SÎO.^ m g* t oa on *a m o o o f- ~ H_t- n_«c a® 15-14

m 15 % Android fe^SHSijEI-

AiiiiKjiik/j. wfieiiiiiM«»« -%-m. {hmmtvit Android mm®, nmmmtmi* & s <\. it % $ & \M '¡< w » « »(!ir i B # #ij rt«j m m & -ft w. w +1 i Kv: m tit * eg r.

mvjammu finm/jiimitfrim. jt«t&&M$)R 4 Mtz&.&mmm

^mcMc/m', fc "J W I -.ft SU Android Market L^-Cli j', 4nB0 15-17

0 0

Post a comment