There were fireworks Tuesday at a key hearing in the Bill Cosby sexual assault case — with even the comedian piping up.

The 79-year-old TV star, who is typically silent during proceedings, blurted out the location of a hotel in response to a question posed by the judge to attorneys.

It was an unexpected moment in a day so full of outbursts that the judge had to repeatedly admonish the lawyers to stop shouting and at one point suggested the police could intervene.

"You don’t want to get involved with the Sheriff’s Office if you can’t control yourselves," he told them.

The hearing is of critical importance to the case. At issue is whether 13 sex-abuse accusers should be allowed to testify against Cosby at his trial this summer.

Prosecutors say the women were drugged and molested by Cosby and that their accounts show a pattern of behavior. Cosby's attorneys have cast doubt on the women's memories and motivations.

Related: Cosby's Entire Trial May Rest on This Case Law

It will be up to Montgomery County Judge Steven O'Neill to decide whether a jury gets to hear from the women, whose allegations span decades.

"That's the whole case right there," said Wes Oliver, the criminal justice program director at Duquesne University and an NBC News analyst.

Despite the high stakes, Cosby was in a light mood when he entered the courthouse.

"Don't tase me, bro," Cosby told guards, according to the Associated Press, referencing ameme rooted in a 2007 confrontation between police and a college student.

Inside the courtroom, there were few laughs.

The proceedings were contentious from the start, with prosecutors trying to block the defense's attempt to introduce exhibits that contain the names of the 13 women, at least two of whom have not publicly identified themselves.

It bubbled over when District Attorney Kevin Steele objected to an exhibit that included an email from an accuser asking that she be warned if she has to testify so she could break the news to her father.

"You gave it to us," Cosby attorney Brian McMonagle said of the email.

"It's called discovery," Steele shouted.

The judge then chided both lawyers about their decorum and ordered the defense not to identify the women who did not put their names forward.

In the afternoon session, the two sides were at it again.

They sparred over whether Facebook postings of the accusers could be used to show what the defense called "online collaboration," and whether information about accusers whom prosecutors did not ask to testify should be made public.

Tensions boiled over when the DA stalked over to a projector screen set up for a Power Point presentation by the defense and loudly argued that Cosby's team planned to broadcast the names of the accusers, drawing a protest from McMonagle.

The judge put up his hands, spoke over them and hinted that the sheriff could be called in.

Cosby is charged with drugging and sexually attacking Andrea Constand during an encounter in his Pennsylvania home in 2004. It is the only criminal case stemming from dozens of accusations of sexual misconduct — all of which he has steadfastly denied.

Because there is only one accuser in the case, the prosecution's success could depend on whether the so-called "prior bad act" witnesses are allowed to take the stand.

"Let's say you can get a jury that's never heard of all these allegations against Cosby. Who do they see? Mortimer Ichabod Marker from 'Captain Kangaroo,' the guy from 'I Spy,' Cliff Huxtable. I remember when the allegations came out someone saying, 'Going after Bill Cosby is like going after Santa Claus.'

"Bill Cosby against one woman when the standard is reasonable doubt? Cosby has a really good chance of winning that," Oliver said. "But once you introduce into this mix that there's a good chance he's done things like that before, the jury starts to think there's a really good chance he did it this time, too."

Related: Bill Cosby's Accusers Hope to Testify at His Sex Assault Trial

Many states and the federal government subscribe to what's called the "lustful disposition rule," which allows accusations of prior sexual misconduct to be used against someone charged with a sex crime, Oliver said.

Pennsylvania is not one of those states and instead evaluates whether prior sexual misdeeds show a defendant has a "common plan" or strategy in committing sexual impropriety. If the court decides the defendant does, the earlier accusations can be admitted.

Oliver said courts in all states, including Pennsylvania, are more likely to admit prior acts than keep them out of a sex-crime case. And O'Neill has already ruled against Cosby several times, including a recent decision to allow prosecutors to use his deposition in a civil lawsuit filed by Constand in which he talks about giving Quaaludes to women for sex.

Cosby has also tried unsuccessfully to convince the judge that a former district attorney who didn't charge him in 2005 promised he would never face charges and that he is too blind to assist in his own defense.

The 13 women who have agreed to testify against Cosby were apparently chosen — from a group of almost 60 who have accused the comedian since the scandal exploded last year — because their stories align most closely with Constand's account.

Seven allege that they consumed spiked drinks; six say they were given pills before being assaulted. Some of the accusations date back to the 1960s.

One of the potential witnesses, Donna Motsinger, has told NBC News that when prosecutors asked if she would testify, she didn't have to think it over.

"I said yes and I didn't hesitate at all," Motsinger, 74, said in September. "If there's any way I can bring some kind of closure for all these victims, what kind of a person would I be if I said no?"