Hey there,
It seems you use headphones when you have this error, right ? If so, are the headphones you use third-party?
If the headphones you are using is third-party, this error may occur to you as a result of the speaker's incompatibility with the device.
There is a trick you can do to fix this error, but I will not guarantee that this problem will be fixed in the long term, which is through remove the headphones and play the music and then, reinsert the headphone.
about Heating iPhone:
When you use the device or charge the battery, the device might get warm. You might notice that your device feels warmer in these situations:
When you set up your device the first time
When you restore from a backup
When apps reindex or reanalyze data, like Photos tagging for faces, places, or keywords after a software update
When you use graphics-intensive or augmented-reality apps or features
These conditions are normal, and your device will return to a regular temperature when complete.
Here are some of the higher ambient-temperature conditions and activities that might cause the device to change performance and behavior:
Leaving the device in a car on a hot day.
Leaving the device in direct sunlight for an extended period of time.
Using certain features in hot conditions or direct sunlight for an extended period of time, such as GPS tracking or navigation in a car, playing a graphics-intensive game, or using augmented-reality apps."
Check out this article ☞ If your iPhone, iPad, or iPod touch gets too hot or too cold - Apple Support