PARKLAND, FLA. -- An off-duty police officer who was at Florida's Parkland high school during the 2018 massacre testified Thursday at the trial of the deputy accused of not stopping the shooter, describing how he mistook gunshots for fireworks before realizing what was happening and approached unarmed.

Coral Springs Sgt. Jeffrey Heinrich, testifying for a second day for the prosecution, said he initially thought the shots were coming from in or near the Marjory Stoneman Douglas High classroom building where the 17 murders occurred. But it wasn't until he interviewed a wounded student several minutes after the shooting started that he knew for certain.

He conceded that he never got within 200 yards (182 metres) of where former Broward Deputy Scot Peterson had taken cover on the opposite side of the building and never saw the deputy.

What Peterson, 60, heard and saw on Feb. 14, 2018, is the key issue in the trial. He is charged with failing to confront shooter Nikolas Cruz before the gunman reached the 1200 building's third floor, where six of the victims died.

Peterson is not charged in connection with the 11 deaths on the first floor, before he reached the building. He never entered the building, taking cover nearby. He insists he did not know where the shots were coming from.

If convicted, Peterson could be sentenced to nearly a century in prison.

Heinrich testified he was watering the baseball field about 200 yards (metres) away from the 1200 building whe the shooting began. His son played for the school team and Heinrich was a volunteer groundskeeper at the school, where his wife teaches physical education.

He said he heard loud bangs, but having worked as a school police officer, he just thought a student had set off firecrackers. And though he then heard the fire alarm go off, he only began to suspect gunshots when he saw panicked students running from the building. He dropped the hose and ran toward the buildings, even though he was unarmed and dressed in shorts and a T-shirt.

鈥淢y training is that you run toward the sound of gunshots,鈥 he said. 鈥淚t was just instinct.鈥 He said officers are told to get to the shooter because every gunshot is potentially another death.

He said he ran past an unarmed security guard who told him there was an active shooter and that an assistant football coach had been shot. But he said he couldn't tell if the shots were coming from inside the 1200 building, a neighboring building or their rooftops.

He then went into a parking lot, finding student Kyle Laman wth part of his lower right leg blown off and fearing he could bleed to death. He heard a voice he believed was a police officer yelling 鈥淭hey are shooting at us鈥 and telling them to get down.

Heinrich said he rushed Laman to a baseball locker room where he stemmed the bleeding until paramedics arrived. It was then Laman told him he had been shot on the 1200 building's third floor. He called his dispatchers.

He went back outside and saw one of his Coral Springs colleagues, who had an extra bullet-resistant vest and handgun. He donned the vest, grabbed the gun and they returned to the building, which was now being searched by other officers who had since arrived. They stayed outside so they wouldn't draw friendly fire.

Peterson's attorney, Mark Eiglarsh, on cross-examination, emphasized that Heinrich also couldn't tell where the shots were coming from. Heinrich said that was true, but that if he had been armed he would have gone toward where he thought they were until he found the shooter.

Laman, now 20, also took the stand Thursday, showing jurors his scarred, damaged leg. He broke down when prosecutors played security video of him and the others being shot on the third floor, adding his pain is so severe at times it makes him unable to walk.

Under cross-examination by Eiglarsh, Laman said he did not hear the shots Cruz fired on the first and second floors because of the fire alarm, but knew exactly what was happening when he saw Cruz firing on the third floor.

The most serious charges against Peterson are seven counts of felony child neglect for four students killed and three wounded on the third floor.

For Peterson to be convicted of child neglect, prosecutors must first show he was legally a caregiver to the juvenile students - defined by Florida law as 鈥渁 parent, adult household member or other person responsible for a child's welfare.鈥

If jurors find Peterson was a caregiver, they must determine whether he made a 鈥渞easonable effort鈥 to protect the children or failed to provide necessary care.

Peterson is the first U.S. law enforcement officer ever charged for an alleged failure to act during a school shooting. Similarly, Texas authorities are investigating officers in the town of Uvalde who didn't confront the shooter who killed 19 elementary students and two teachers last year. None have been charged, however.

The trial began Wednesday and is expected to last up to two months.

Cruz, 24, pleaded guilty and last year received a life sentence.