Prosecutors allege that Vila's recording of a phone conversation during which he argued with the judge was a violation of Maryland's wiretap laws. Vila is also charged with playing the recording — which he says was accidental — for colleagues on two occasions.

The case arose from a dispute on a Saturday night between Vila and District Judge Joan B. Gordon over the urgency of a shooting investigation. Police wanted to search a car where the victim had been found, but the judge thought it could wait until Monday.

Police and judges commonly discuss warrants outside of regular working hours. In court Friday, Gordon testified that she is required to be on call one week every year so she can review warrant applications when courthouses are closed.

But that Saturday, the judge and investigators could not agree on the urgency of the shooting investigation. According to testimony Friday, they soon got into an argument over the phone.

"The tenor was a very hostile one," Gordon said in court.

Worried that the incident could lead to a complaint against him, Vila said he only intended to record his side of the conversation. The sergeant testified that he only made the recording of the judge's voice because he accidentally turned on the speaker of his cellphone.

His lawyer, Catherine Flynn, argued that because it was an accident, he did not do anything illegal.

"It was my intention to capture myself, and only myself," Vila said in court.

But Assistant State's Attorney Paul Pineau asked Vila whether he had ever used a speakerphone before and whether he noticed the volume of the phone changing.

Vila said he replayed the conversation once for Detective James Clark immediately after he recorded it, and again for another colleague who was facing a complaint about discourtesy. He said he did not think he had done anything wrong by making the recording and thought it would be OK to play it.

Vila and Clark had worked through Friday night and into Saturday evening investigating the shooting, and Clark prepared a search warrant. Clark was the first to get in touch with Gordon, asking her to sign off on the search.

Gordon raised questions about the application that night and asked to speak to Vila, Clark's supervisor.

In the recording, which was played in court, Vila can be heard reminding the judge of her responsibilities.

"It's your duty, your honor. You're on call," he said.

Gordon can then be heard saying she wanted to talk to Vila's supervisor and gather more information.

"I explained to you why it was necessary for us to be inside this vehicle," Vila said. He added that he did not want to bother his lieutenant, who was not at work: "You're on call. He's not on call."

It is not clear what concerns Gordon had about the warrant application. Judge Lawrence Daniels, who is presiding over Vila's case, has barred any discussion of the underlying investigation.

In arguments that took place while jurors were out of court, Daniels said he feared they might go easy on Vila if they knew the case concerned a shooting.

Gordon testified that she was trying to determine whether the warrant was an emergency that would justify a detective coming to her house on a Saturday evening.

Flynn, Vila's lawyer, questioned her in response: "You're aware that crime occurs 24 hours a day. Is that correct?"

Gordon said she was. She said she signed another warrant for Clark in the early hours of that Sunday morning.

Baltimore police officers may not "prevent or prohibit" people from taking photographs or video of crime scenes and other law enforcement activities that are in public view, according to a department-wide directive made public Friday.