I would add what mercuryus suggested plus change the order of the instructions a little bit:
Code:
if(level_code == 1)
{
var hdl;
freeze_mode = 1;
hdl = media_play("level2b.avi",null,50);
while(media_play(hdl) == on) { wait(1); }
level_load("level2b.wmb");
wait(3);
p1_health = 100;
player.health = 100;
level_code = 2.2;
freeze_mode = 0;
AIpath();
}