Skip to content
LRain edited this page May 17, 2021 · 2 revisions

Simple usage

If you just want to use it with Netease Cloud Music's playlist.

Then, you can just set a property with your playlist ID called penguinplayer_id in the window context, and it must be the string type.

Advanced usage

Actually, there is another way to initialize the player.

When the player is loaded, it will add an object inside window. The object contains various APIs for you to use.

And in here, we will need window.PPlayer.initialize to initialize the player.

As the documentation, you can pass a string directly to use a Netease Cloudmusic playlist by default. Or you can pass a PenguinPlayerOptions to take more control with the player initialization.

For example, I want to initialize the player with an audio file, a Netease Cloudmusic playlist and a QQ Music playlist.

PPlayer.initialize({
    playlist: [
        {
            type: "file",
            options: [
                {
                    url: "demo.mp3",
                    name: "Demo",
                    artists: ["Anonymous Artist"]
                }
            ]
        },
        {
            type: "netease",
            options: "2717890285"
        },
        {
            type: "qq",
            options: "7998526029"
        }
    ]
});

Then you will get the player initialized with the playlists you want!

For more usages, check the API documentation

Clone this wiki locally