Sounds like theres something wrong with connector, the easiest way to diagnose it is to replace the ribbon (the one attached to display shield) as they’re siper cheap if the problem wont go then it’d be the connector on board and to replace that you’d need hot air station, ideally microscope and lots of skill. you can also grab a magnifying glass and check the on board connector for debris before replacing the ribbon.
https://www.ebay.co.uk/itm/OEM-Replacement-Housing-Back-Battery-Cover-for-iPhone-6-6s-6-6s-7-7PLUS/291726925812?hash=item43ec479ff4:m...-Yjr2qijxQ:rk:4:pf:0 here for example, just picked one at random.
Open the phone take the shield off the connectors and disconnect and connect the digitizer connector, same thing happened when my daughter dropped her 6, the connector popped off and one line on the left wasn’t responsive.
Try to move the wire a bit around the jack while playing music, if at any point you’ll hear the music in dead speaker you’ll have to chop the cable above the damaged part and solder new jack on, you can also reuse the old jack if the damage is far enough from it, but that would be less aesthetical solution. There’s also an option that the driver itself is dead, but i would place my bet on the cable near the plug.