Only passive buzzers can play music, and the sound of active buzzers is fixed.
To drive the buzzer, just give it a flipped level, but this level must have sufficient driving capability. That is to say, it not only has a flipped level, but also can output enough current.
Another important point is that the frequency of this flipped level must be within the audio range, about 100hz~15khz.