Heh, it's hard to say! In this particular case, I think he was scared of the box and what may or may not pop out of it. You can tell he was soooo excited, but he was nervous, too. Poor guy. If we'd let him inspect it for a few minutes before showing him what was inside he probably would've gotten a bit more vocal. In general, he's afraid of most boxes, though -- maybe he had a bad experience w/ a jack-in-the-box or something?!
In other circumstances not involving boxes, though, it's
consistent training.
When he begins the barking/whining to get our attention, we say "Quiet" once and wait til he is quiet for about 30 seconds. Then we praise him, pet him, give him a treat and say, "Good quiet!" For the first couple of weeks or so we did this
every single time. Now, it's more of a habit, so we don't always have to reinforce with anything more than a "Good quiet!" but he still gets petting (and treats if we happen to have them on hand) every now and then.
The other side of the coin is "Speak." He can't be quiet all the time! So, when he starts his whining and barking, we do the "Quiet" routine, but then we also play with him and tell him "Speak!" Then he barks and gets excited and we play and stuff.
In this way, he still gets what he wants--our attention--most of the time, but he understands "Quiet" when we are out or have guests or whatnot.
Anyway, I didn't intend for this to be a dissertation, but it just kind of ended up that way. Basically, all that to say -- CONSISTENCY!
Hope this helps