moved getmedia into socket.onopen