Make sure you assign NewMediaSoundComponent and MediaPlayer to some other Actor’s or UObject’s UPROPERTY, or call AddToRoot() to attach them to the root set, otherwise they will get garbage collected shortly after you created them.
Take a look at SMediaPlayerEditorOutput::Construct, for example.
When you’re done using your objects, make sure you clear the property that holds them / remove them from the root set, otherwise you’ll leak memory.