How does WeChat Mini Programs keep the status of child pages?

I just got in touch with Mini Program developer and recently encountered this problem when I wrote the demo, of a music player. After I returned to the list page from the playback page (or to the home page), I entered the playback page from the entrance of the list page (or home page). I wanted to keep the previous music playback status, instead of loading the playback page again and letting it play again. What special API is available?

~


use wx.playBackgroundAudio ,


https://mp.weixin.qq.com/debu.


The

player is for the current page, and the page has been refreshed and reloaded of course.
Global player has three solutions:

  1. single page program vue,angular,react. Mini Program obviously does not support it.
  2. frame nesting is obviously not supported by Mini Program.
  3. globally play Mini Program's wx.playBackgroundAudio

you can put the playback event in app.js or a separate module.


I also made a music playback Mini Program. I created the background music player in the app instance and saved the current music status. No matter which page you jump, just change the status in the global app.js.

Menu