How to control volume of speaker with Arduino?

Hi. I want to control the volume of my speakers with arduino and some transistors. Please, how to do it? Must I analog.write to resistor B(base of transistor) and then connect output of my mp3 player to E(emitor of transistor) and output will be on C(colector of transistor)? Or is there any easier way to control it?

Thank you.

You can't do it that way it dosn't work. You need a digital pot, google for that.