After trying several things I have found what seems to be a solution for the somewhat common issue of sound crackling durimg media playback.
Clear cache of the affected items,
Hold power button and volume down button for a soft reset of device (doesn't remove any data)
After phone restarts the issue should be solved.
It has fixed both mine and partners phone issue so far for a week with no issues on any media playback service (YouTube, Netflix, Spotify etc)
Hope this helps.