The fatal beating of a metal band's bassist was accidentally caught on video by Facebook Messenger on the alleged assailant’s cellphone, according to a Maine state police affidavit.

A woman, who was not identified, told police the video captured by the phone in Donald Galleck’s shirt pocket showed him punching the victim and pounding his head on a street.

Galleck, 29, was charged last year with murder in the death of Jason Moody, 40, of Bangor, a bassist who performed with the metal band Seize the Vatican.

The affidavit became public Tuesday when Galleck appeared in court to plead not guilty at the Penobscot Judicial Center in Bangor, the Bangor Daily News reported. The document had been sealed since his Nov. 16 arrest.

The woman who saw the video reported it appeared the victim threw the first punch but then apologized.

The woman said she saw the video when she accepted a call from Galleck through the Facebook Messenger app and later received a video chat request from Galleck that she accepted. Galleck allegedly put the phone in his pocket when he sent the video request and it's unclear if he was aware it was streaming. It was not immediately clear from the court document whether the Facebook chat was saved or could be retrieved by investigators.

DEFENDANT GETS 40 YEARS, BLAMES GENDER IDENTITY STRUGGLE FOR FATAL STABBINGS OF PARENTS

Moody was found lying unconscious in November before he was transported to the Northern Light Eastern Main Medical Center where he later died from his injuries on Nov. 13, the Bangor Daily News reported. His cause of death was “massive inflicted trauma to the brain,” the medical examiner said, according to the affidavit.

The two men allegedly got into an argument after Moody asked Galleck to leave his apartment because Galleck was fighting with Moody’s girlfriend.

The Associated Press contributed to this report.