[±ÏÒµÂÛÎÄ]AndroidÔÚÏßÒôÀÖ²¥·ÅÆ÷Éè¼ÆÓëʵÏÖ ÏÂÔØ±¾ÎÄ

Î÷ÄϿƼ¼´óѧ±¾¿ÆÉú±ÏÒµÂÛÎÄ I

AndroidÔÚÏßÒôÀÖ²¥·ÅÆ÷Éè¼ÆÓëʵÏÖ

ÕªÒª£ºÒƶ¯»¥ÁªÍø·¢Õ¹Ë²Ï¢Íò±ä£¬ÒÔÍùµÄËæÉíÌý¡¢MP3µÈǧƪһÂɵIJ¥·ÅÉ豸ÒѾ­Ô½À´Ô½ÄÑÒÔÂú×ãÈËÃǶàÑù»¯µÄÌýÒôÀÖÐèÇóÁË£¬¶øÊÐÃæÉϵÄÒôÀÖ²¥·ÅÆ÷APPÈ´ÉîÏÝÉÌÒµµÄäöÎУ¬Ó¯ÀûºÍÓû§ÌåÑé×ÜÊÇÄÑÒÔ³ÉÕý±È£¬¿´ËÆÁÕÀÅÂúÄ¿µÄÒôÀÖÓ¦ÓÃȴûÓм¸¿îÕæÕýÈÃÓû§Ï²»¶µÄ¡£ÔÚÕâÑùµÄ±³¾°Ï£¬¿ÎÌâ»ùÓÚAndroid¿ªÔ´Æ½Ì¨£¬Ê¹ÓÃJavaÓïÑÔ¿ª·¢£¬²ÉÓÃAndroid Studio + Gradle¹¤¾ß¹¹½¨£¬²¢ÒÀ¿¿OkHttp+GsonÌá¹©ÍøÂç¿ò¼Ü£¬¿ª·¢ÁËÒ»¿îAndroidÔÚÏßÒôÀÖ²¥·ÅÆ÷¡£²¥·ÅÆ÷Ö§³Ö²¥·ÅÔÚÏßÒôÀÖ£¬ÉÏÒ»Çú¡¢ÏÂÒ»Çú£¬Çл»²¥·Åģʽ£¬Ö§³Ö¸è´ÊÓëר¼­·âÃæÏÔʾ£¬Ö§³ÖËÑË÷¡¢ÏÂÔØÔÚÏ߸èÇúµÈ»ù±¾¹¦ÄÜ£¬²¢À©Õ¹ÊµÏÖÁËÒ¹¼äģʽ£¬¶¨Ê±¹Ø±ÕµÈ¹¦ÄÜ£¬ÖÂÁ¦ÓÚ¸øÓû§Ìṩ¸üÊæÐĵÄÌý¸èÌåÑé¡£ÂÛÎĸø³öÏêϸµÄ¿ò¼ÜÉè¼Æ£¬ÏµÍ³Á÷³ÌÉè¼Æ£¬²¿·ÖÉè¼ÆÍ¼¼°Ö÷Òª¹¦ÄÜÔËÐÐÁ÷³Ìͼ£¬²¢¶Ô¿ª·¢ÖÐÓöµ½µÄÖ÷ÒªÎÊÌâ½øÐÐÁËÏêϸÌÖÂÛ£¬Èçͨ¹ýActivityºÍServiceͨÐÅʵÏÖºǫ́²¥·Å¡£¾­¹ýϵͳ²âÊÔ£¬ÏµÍ³ÊµÏÖÁË»ù±¾¹¦ÄܺÍÀ©Õ¹¹¦ÄÜ£¬ÐÔÄÜ´ïµ½ÁËÒ»¶¨µÄÖ¸±ê¡£

¹Ø¼ü´Ê£ºÔÚÏßÒôÀÖ£»²¥·ÅÆ÷£»¶¨Ê±¹Ø±Õ£»Gradle£»OkHttp

Î÷ÄϿƼ¼´óѧ±¾¿ÆÉú±ÏÒµÂÛÎÄ II

Design and Implementation of Android-based

Online Music Player

Abstract: The development of mobile Internet is constantly changing, the previous Walkman, MP3 player and other devices have been stereotyped increasingly difficult to meet people's demand for a variety of music, and the music player market, APP has deep whirlpool business, earnings and proportional to the user experience is always difficult, seemingly dazzling music application did not allow several users to really like it. In this context, an object based on the Android open source platform developed using the Java language, using Android Studio + Gradle build tool, and rely OkHttp + Gson provide network framework, developed an Android online music player. Player supports playback of online music, the song, the next song, switch the playback mode, support for lyrics and album art display, supports searching, downloading songs online and other basic functions, and expanded to achieve a night mode, time off and other functions, is committed to to provide a more enjoyable experience of listening to music. Paper gives a detailed framework design, system design process, part of the design and operation of the main function of a flow chart, and the development of the main problems encountered were discussed in detail, for example, by Activity and Service Communication between Play in background. After testing the system, the system to achieve the basic functions and extensions, reach a certain performance targets.

Keywords: online music, player, time off, gradle, okhttp

Î÷ÄϿƼ¼´óѧ±¾¿ÆÉú±ÏÒµÂÛÎÄ III

Ŀ¼

µÚ1Õ Ð÷ÂÛ .................................................................................................................... 1

1.1 ±³¾° ................................................................................................................... 1 1.2 ¹úÄÚÍâÏÖ×´ ....................................................................................................... 1 1.3 Ä¿±ê¼°·¶Î§ ....................................................................................................... 2 1.4 ºËÐļ¼Êõ ........................................................................................................... 3 µÚ2Õ AndroidÒôÀÖ²¥·ÅÆ÷ÐèÇó·ÖÎö .......................................................................... 5

2.1 ¹¦ÄÜÐÔÐèÇó·ÖÎö ............................................................................................... 5

2.1.1 ±¾µØÒôÀÖ ................................................................................................ 5 2.1.2 ÔÚÏßÒôÀÖ ................................................................................................ 6 2.1.3 ÔÚÏßËÑË÷ ................................................................................................ 8 2.1.4 ²¥·Å¿ØÖÆ ................................................................................................ 9 2.1.5 À©Õ¹¹¦ÄÜ .............................................................................................. 12 2.2 ·Ç¹¦ÄÜÐÔÐèÇó·ÖÎö ......................................................................................... 14

2.2.1 Èí¼þÐÔÄÜÖ¸±ê ...................................................................................... 14 2.2.2 Èí¼þ¼æÈÝÐÔ .......................................................................................... 14

µÚ3Õ AndroidÒôÀÖ²¥·ÅÆ÷ϵͳ¸ÅÒªÉè¼Æ ................................................................ 15

3.1 Ö÷ÒªÉè¼ÆÄÚÈÝ ................................................................................................. 15 3.2 Éè¼ÆË¼Ïë ......................................................................................................... 15 3.3 ϵͳ¿ò¼Ü ......................................................................................................... 16 3.4 ϵͳ¹¦ÄÜ ......................................................................................................... 17

3.4.1 ±¾µØÒôÀÖ .............................................................................................. 17 3.4.2 ÔÚÏßÒôÀÖ .............................................................................................. 18 3.4.3 ÔÚÏßËÑË÷ .............................................................................................. 18 3.4.4 ²¥·Å¿ØÖÆ .............................................................................................. 19 3.4.5 À©Õ¹¹¦ÄÜ .............................................................................................. 19 3.5 Á÷³ÌÉè¼Æ ......................................................................................................... 19 µÚ4Õ AndroidÒôÀÖ²¥·ÅÆ÷´æ´¢Éè¼Æ ........................................................................ 21

4.1 ±¾µØ´æ´¢ ......................................................................................................... 21

Î÷ÄϿƼ¼´óѧ±¾¿ÆÉú±ÏÒµÂÛÎÄ IV

4.2 Ô¶³Ì´æ´¢ ......................................................................................................... 22 µÚ5Õ AndroidÒôÀÖ²¥·ÅÆ÷ÏêϸÉè¼ÆÓëʵÏÖ ............................................................ 23

5.1 ϵͳ¼Ü¹¹ÏêϸÉè¼Æ ......................................................................................... 23

5.1.1 ϵͳ¼Ü¹¹·½Ê½·ÖÎö .............................................................................. 23 5.1.2 ϵͳ¿ò¼Ü·ÖÎö ...................................................................................... 24 5.1.3 ÍøÂçÇëÇó¿ò¼Ü·ÖÎö .............................................................................. 27 5.1.4 Êý¾Ý»º´æ¿ò¼Ü ...................................................................................... 28 5.2 ¹¦ÄÜÏêϸÉè¼Æ ................................................................................................. 30

5.2.1 ±¾µØÒôÀÖÏêϸÉè¼Æ .............................................................................. 30 5.2.2 ÔÚÏßÒôÀÖÏêϸÉè¼Æ .............................................................................. 32 5.2.3 ÔÚÏßËÑË÷ÏêϸÉè¼Æ .............................................................................. 34 5.2.4 ²¥·Å¿ØÖÆÏêϸÉè¼Æ .............................................................................. 35 5.2.5 À©Õ¹¹¦ÄÜÏêϸÉè¼Æ .............................................................................. 37 5.2.6 ¹¦ÄÜÉèÖÃÏêϸÉè¼Æ .............................................................................. 39 5.2.7 ¹ØÓÚ½çÃæÏêϸÉè¼Æ .............................................................................. 41

µÚ6Õ AndroidÒôÀÖ²¥·ÅÆ÷ϵͳ²âÊÔ ........................................................................ 43

6.1 ¹¦ÄܲâÊÔ ......................................................................................................... 43

6.1.1 ²âÊÔ»·¾³ .............................................................................................. 43 6.1.2 ²âÊÔÓÃÀý .............................................................................................. 43 6.1.3 ²âÊÔ½áÂÛ .............................................................................................. 44 6.2 ¼æÈÝÐÔ²âÊÔ ..................................................................................................... 45 ½áÂÛ .................................................................................................................................. 47 ÖÂл .................................................................................................................................. 48 ²Î¿¼ÎÄÏ× .......................................................................................................................... 49