CodePudding user response:
With the intent and you are not too understand how item click? Throw click write interfaceCodePudding user response:
This is my biography and eventActivity1:
Intent Intent=new Intent (MainActivity. This, PlayActivity. Class);
String path=musicInfos. Get (position). GetPath ();
String title=musicInfos. Get (position). The getTitle ();
Intent. PutExtra (" uri ", path);
Intent. PutExtra (" title ", the title);
StartActivity (intent);
Finish ();
Activity2:
Intent Intent=getIntent ();
String path=intent. GetStringExtra (" uri ");
String title=intent. GetStringExtra (" title ");
Uri Uri=Uri. Parse (path);
//the Log i. (" uri ", path);
Start=the findViewById (R.i d.p lay_start);
//start. SetBackgroundResource (R.d rawable. Ic_media_play);
TextView=the findViewById (R.i which extView_music);
Play_next=the findViewById (R.i d.p lay_next);
Player=MediaPlayer. Create (this, uri);
TextView. SetText (title);
Player. Start ();
Start. SetOnClickListener (new View. An OnClickListener () {
@ Override
Public void onClick (View v) {
{if (player. IsPlaying ())
Player. Pause ();
The Log i. (" play ", "play");
} else {
Player. Start ();
}
}
});
But the first song when I click other songs will not pause will continue to play, why he
CodePudding user response:
Player=MediaPlayer. Create (this, uri);The palyer is a new object, not the same, so before the palyer is still in play
Advice or write in the service
CodePudding user response:
That is when I preach the ginseng mainactivity to service inside? For the parameters of the mentally