How can I stop sound switching to internal if I close the lid on my MacBook while playing video on HDMI-connected TV
You didn't mention what media player you're using. 

Personally I use VLC Media Player. With VLC you can explicitly set the audio device in the menubar > audio > Audio Device > HDMI, in your case. I use VLC in conjunction with NoSleep to close my laptop while playing media. The screen turns off when I close the lid, but the computer stays awake. The brightness button also will step/dim down to "display off" on my laptop. I usually opt to do it this way instead of closing the lid all the way so as to be able to pause and play and also to keep the laptop from getting hot. Not sure if an older model like yours will do that, do let me know.