In android applications, there is a class without UI (android. app. Service) -- Service. To put it simply, the Service is a background process (background Program). Through the background program, you can implement some functions that do not require UI, such as playing background music.
The following is a routine for p
Service-based music player for Android Development
This is a Service-based music player. The program's music will be played by the background Service component. When the background playing status changes, the program sends a broadcast notification to the foreground Activity update interface. When you click the foregrou
.
Step17Press OKagain.
Part VI, install Google Play:Step18Repeat step 15 drag Gapps to Genymotion and press OKagain.
Step19After the installation, the genymotionwas re-initiated.
article VII, install Android APP (Magic Tower):Step20Click Google Play.
Step21Enter Google account.
Step22Then you can download and install the Magical Tower !
Step23Th
); StartService (Intent);//exit Current Activity This. Finish (); }Else if(V.getid () = = R.id.btnstop) {//Stop playing musicIntent Intent =NewIntent ( This, Musicservice.class); StopService (Intent); } }}After we clicked the button "play music and exited activity", we first started musicservice through the activity's startservice, and then we immediately called the activity's finish method to destroy the current activity. You ma
class extends Binder implements IRemoteService. You can manually write a PlayerService to play the music. You need to use the android. media. MediaPlayer class to play the music. The Code is as follows:
Package pandafang. demo. playerserver; import java. io. fileDescriptor; import java. io. IOException; import android
effects cannot be captured .. That is, rotate a circle .. Nothing nice .. ...
Paste the code of the activity and service in the playlist ~~ These two are critical ~~
Package COM. musicplayer; import android. app. activity; import android. content. intent; import android. OS. bundle; import
create the directory raw in res, and then add MP3 files to it.
Inherit a service class:
Package COM. moruna. studys; import android. app. service; import android. content. intent; import android. media. mediaplayer; import android. OS. ibinder; public class myservice exten
Android enables online music playingHello, friends, the first blog published by Shanshan in August. Recently, Wu was looking for a job, and when she got sick, she didn't have much energy to write a blog. Today, I am dragging my head to publish an article about the online music effect that has been achieved previously. It is not difficult to play
Ding Lang suggestion: before learning this instance, Please master the Activity lifecycle related events and methods, so that the learning effect will be better.This instance is for reference only and is not a perfect product. Due to time and technical limitations, we apologize for any shortcomings or errors. Hope enthusiastic netizens can continue to improve.Below is part of the Activity code (I usually have detailed comments ):
Package cn. chaoyang. activity;Import java. io. File;Import java.
This article describes an online music player. The operations are described in detail to achieve the effect and understand the principles of the player.
Source code:
Layout file:
Activity_audio_httpplayer:
AudioHTTPPLayer. java:
Package com. multimediademo7audiohttpplayer; import android. app. activity; import
Article Description: thinking of the Android App store.
Melee, messy, and uneven, this is a idiomatic expression of the status of the domestic Android Third-party App Store. Behind the impetuous disputes, there is a lack of thinking about the App store itself. The
)Explanation: no return value. Set whether to use SurfaceHolder for display.
Method: setVolume (float leftVolume, float rightVolume)Explanation: no return value. Set the volume.
Method: start ()Explanation: no return value. start playing.
Method: stop ()Explanation: no return value. Stop playing.4. demo of complete music playbackImplemented functions:1. Pause/play, next/previous, and click a start to play2. Supports dragging progress ba
, have friends if know for Android, request recommended!Two. Scan local music filesFirst through the QQ music has downloaded the good song.Scan implementation://scan local musicif(Environment.getexternalstoragestate (). Equals (environment.media_mounted)) {NewThread () {@Override Public void Run() {Try{string[] ext = {". mp3"}; File File =NewFile (
The music of a general Android app can be divided into background music and sound effects when you click various controls. The former is generally a relatively large music file, and the latter is generally a relatively small music
Recently started learning audio related. So, I really want to do a music player, so, spent a day to learn, the player's basic skills can be realized. I think the learning point is still quite a lot of, so write a blog summary about a music player implementation of the logic. I hope this blog post is helpful to your study and life. :* * Implement Logic * *On the market M
suitable for Android, request recommend!
Second, scan local music files
First through the QQ music has been downloading good songs.Scan implementation:
Scan local Music
if (Environment.getexternalstoragestate (). Equals (environment.media_mounted))
{
new Thread ()
{
@Override public
Void Run ()
Suggestion: before learning this instance, Please master the activity lifecycle related events and methods, so that the learning effect will be better.
This instance is for reference only and is not a perfect product. Due to time and technical limitations, we apologize for any shortcomings or errors. Hope enthusiastic netizens can continue to improve.
Below is part of the activity code (I usually have detailed comments ):
Package CN. chaoyang. activity; import Java. io. file; import Java. io. io
This article introduces the MediaPlayer local music player. When the application is no longer on the frontend and is not using it, we need to establish a Service to ensure that the audio continues to play.
Interaction between Activity and Service binding is the focus of this article (here we need to note that Activity cannot directly access methods in Service objects, so we have introduced it here, this is also a consideration for service security and
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.