Yes, the Necromancer is driven from Mirkwood, nowhere is Gandalf captured and restrained (and if he were, The Enemy would almost certainly have taken Narya from him).
Besides, per Fellowship, Gandalf could not have encountered the Necromancer in such a way because they were not aware of Sauron’s *secret* activities as he regathered his former strength. In a “face to face” meeting Gandalf would recognize Sauron.
I’ll step off my soapbox, now.
I haven’t seen any of the LOTR movies but I love the music by Howard Shore. How good are the movies?