There are several factors. It really depends on the situation. Most people trapped in house fires pass out and die of Asphyxiation, hypoxia or heat exhaustion before their bodies burn. On the other hand there is a YouTube video where a young man is trapped in his car from a wreck and you can hear his screams for several minutes. Factors include how hot the fire, how big the fire, access to oxygen, distance your body is from the fire, how fast the fire, and which parts of the body burn first. Also take into account, the person needs not to actually catch on fire to feel the painful effects of burning. Just being close to a fire can cause screaming pain for minutes before the fire even begins to consume them. As for the one you mentioned about the girl trapped. Unable to move, she most likely died of hypoxia or suffocated before the fire consumed her. The screaming was most likely pain from thermal heat against her body as the fire drew near.
The one where you described them running around on fire, it took longer to die. They had access to oxygen and therefore didn't have the luck of dying of hypoxia first. Only as the thermal burns consumed their organs did they succumb, Which took several minutes.