A man accused of firing a shotgun at armed police insisted he was aiming "into the sky", a court was told.
Daniel Hannam, 32, is alleged to have fired at officers from the upstairs window of a house in Castle Cary, Somerset, on 23 January.
Body-worn video footage showed two officers, IC and IX, return fire before taking shelter behind a vehicle.
Mr Hannam denies attempted kidnap, two counts of attempted murder and a firearms offence.
Bristol Crown Court was told Mr Hannam later threw the shotgun out of a window and handed himself over to police.
Jurors were told that, while in custody at Bridgwater police station, Mr Hannam said: "I didn't shoot at police officers, I shot out of the window....I shot in the air. Right, I fired a shotgun in the air."
The court heard pellets from the shotgun travelled approximately two metres over the heads of the officers and embedded in the side of an armed response vehicle.
It is alleged Mr Hannam had discharged his shotgun into the air in the town earlier that night and shot at the door of a newsagents.
He then got into the car of Oliver Walter-Taylor, who he did not know, and asked him for a lift, the court heard.
After a struggle, both men got out and Mr Hannam fired the shotgun into the air, with pellets hitting the car, the jury heard.
Jurors were also told Mr Hannam had been released from prison in August 2018 having served a substantial sentence. He was in breach of his licence and was facing recall to prison.
The trial continues.