I am having fun with my friends = Both my friends and I are having fun; we are enjoying each other's company.
I am having fun with the kalaok machine = I am using the machine to have fun; I am enjoying what I can do with the machine.
Basically, if you are having fun with other people, it implies that everyone is having a good time. If you are having fun with an inanimate object (such as a machine), you are using that object, and you are the only person having fun (because the machine cannot have an emotion).