WeChat Mini Program Development | Music Mini Program Project

3.1 Preparations before development

3.1.1 Project display

music appletProject effectexhibit:
insert image description here

3.1.2 Project Analysis

Music applet projectpage structure diagram

  • tab navigation bar
  • content content area
  • player music player control
    insert image description here
    music applet projectDirectory Structureinsert image description here

3.1.3 Project initialization

Developer tools create a blank project:
insert image description here
insert image description here

3.2 [Task 1] Tab switching

3.2.1 Task Analysis

Tabs and Pages(info.wxml, play.wxml, palylist.wxml) structure diagram:
insert image description here

3.2.2 Preliminary knowledge

swiper componentWrite the sliding page structure:
insert image description here
swiper componentCommon properties:
insert image description here
swiper componentWrite the sliding page structure:
insert image description here
includeThe main purpose:

  • Splitting your code into multiple files makes it easier to find your code.
  • Extract the common parts of the code. Introduced via external files.

insert image description here

3.2.3 Writing page structure and styles

Music applet basicspages and styles:
insert image description here
insert image description here
test pageinfo.wxml、page.wxml、play.wxmldocument:
insert image description here
insert image description here

3.2.4 Realize tab switching

clickNavigation BarTabs implement tab switching:
insert image description here
viascroll eventSwitch page effect:
insert image description here

3.3 [Task 2] Music recommendation

3.3.1 Task Analysis

Music recommendation page structure diagram:
insert image description here

3.3.2 Preliminary knowledge

scroll-view componentAttributes and descriptions:
insert image description here
scroll-view componentEvent object:
insert image description here
insert image description here
scroll-view componentEvent object parameter analysis:
scrollLeft: The distance from the left side of the horizontal scroll bar to the left side of the view.
scrollTop: The distance from the upper end of the vertical scroll bar to the top of the view.
scrollHeight: The maximum scrolling distance of the vertical scroll bar on the Y axis.
scrollWidth: The maximum scrolling distance of the horizontal scroll bar on the X axis.
deltaX: The scroll state of the horizontal scroll bar.
deltaY: The scroll state of the vertical scroll bar.
image componentProperties and description:
insert image description here
image componentZoom mode:
Image component scaling mode:
image component9 cropping modes:
insert image description here
image componentZoom mode and crop mode tests:
insert image description here

3.3.3 Content area scrolling

scroll-view component
insert image description here

3.3.4 Carousel image

swiper componentRealize the carousel map:
insert image description here

3.3.5 Function buttons

flex layoutRealize the function button:
insert image description here

3.3.6 Popular Music

flex layoutImplement the page layout:
insert image description here

3.4 [Task 3] Player

3.4.1 Task Analysis

Structural diagram of the player tab page:
insert image description here
analyze the specific functions of the player:
music information: Display the title and artist of the currently playing track.
The album cover: When the music is playing, the album art will rotate clockwise.
playback progress: Display the playback progress and adjust the music progress.

3.4.2 Preliminary knowledge

audioCtx objectThe way of declaration:
insert image description here
Audio APIThe properties and description of the interface:
insert image description here

Audio APIInterface methods and descriptions:
insert image description here
innerAudioContextCase use:
insert image description here
slider componentProperties and description:
insert image description here
slider componentusage of:
insert image description here
insert image description here

3.4.3 Define basic data

Music playlist and music status data:
insert image description here

3.4.4 Realize music playback function

Music playback logic code:

Structure code of the bottom player:
insert image description here
insert image description here
Style code of the bottom player:
insert image description here
Pause/play button control song of the bottom player:
insert image description here
Realize the player switching to the next song:
insert image description here

3.4.5 Write the player page

Player page structure code:
insert image description here
insert image description here
Player page style code: Poster
insert image description here
rotation through CSS3 animation:
insert image description here
Poster rotation through CSS3 animation:
insert image description here

3.4.6 Control playback progress

Slider structure at the bottom of the player page:
insert image description here
insert image description here
Slider style at the bottom of the player page:
insert image description here
Display music playback progress:
insert image description here
Control the length of the progress bar Control the song playback progress:
insert image description here

3.5 [Task 4] Player list

3.5.1 Task Analysis

Control the length of the progress bar to control the playback progress of the song:
insert image description here

3.5.2 Writing page structure and styles

Control the length of the progress bar to control the playback progress of the song:
insert image description here
Control the length of the progress bar to control the playback progress of the song:
insert image description here

3.5.3 Realize the song changing function

Realize the song changing function:
insert image description here

Summarize

This chapter explains the complete development process of the music applet project. The development steps include the analysis of the page structure, the design of the style, and the use of components. Through the study of this chapter, readers can master the development of the basic interactive logic of applets, use API to realize specific functions in the project, and learn to solve common problems in the development process.

Guess you like

Origin blog.csdn.net/PoGeN1/article/details/130117995