In the novel, the sequence of events was somewhat different. Frodo wasn't keen to hand over the ring and attempted to grab it out of the fire but he didn't refuse to throw it into the fire until slightly later:
'Give me the ring for a moment.' [Said Gandalf] Frodo took it from his
breeches-pocket, where it was clasped to a chain that hung from his
belt. He unfastened it and handed it slowly to the wizard. It felt
suddenly very heavy, as if either it or Frodo himself was in some way
reluctant for Gandalf to touch it.
Gandalf held it up. It looked to be made of pure and solid gold. 'Can
you see any markings on it?' he asked.
'No,' said Frodo. 'There are none. It is quite plain, and it never
shows a scratch or sign of wear.'
'Well then, look!' To Frodo's astonishment and distress the wizard
threw it suddenly into the middle of a glowing corner of the fire.
Frodo gave a cry and groped for the tongs; but Gandalf held him back.
later
'Would you? How would you do that? Have you ever tried?'
'No. But I suppose one could hammer it or melt it.'
'Try!' said Gandalf. Try now!'
Frodo drew the Ring out of his pocket again and looked at it. It now appeared plain and smooth, without mark or device that he could see. The gold looked very fair and pure, and Frodo thought how rich and beautiful was its colour, how perfect was its roundness. It was an admirable thing and altogether precious. When he took it out he had intended to fling it from him into the very hottest part of the fire. But he found now that he could not do so, not without a great struggle. He weighed the Ring in his hand, hesitating, and forcing himself to remember all that Gandalf had told him; and then with an effort of will he made a movement, as if to cast it away - but he found that he had put it back in his pocket.
Gandalf laughed grimly. 'You see? Already you too, Frodo, cannot easily let it go, nor will to damage it. And I could not "make" you - except by force, which would break your mind. But as for breaking the Ring, force is useless. Even if you took it and struck it with a heavy sledge-hammer, it would make no dint in it. It cannot be unmade by your hands, or by mine.
Obviously the film is attempting to show this reluctance, bordering on addiction without having to resort to having the characters offer expository dialogue about their feelings.
The key point is that isn't the ring that's reluctant to be thrown on the fire, it's Frodo that's reluctant to part with the ring, let alone place it in (what he perceives to be) danger.