In order to work the MediaElement must be part of the logical tree of your application and therefore must be added to some container (Grid, StackPanel) in your application.
You can add the MediaElement via XAML (as you have done it before) or you can add it during runtime via
LayoutRoot.Children.Add(player);
Instead of using the MediaElement you should use the MediaPlayer class. This will work (at least for me) without attaching it to XAML.
MediaPlayer player = new MediaPlayer();
player.Open(new Uri(fileName, UriKind.RelativeOrAbsolute));
player.Play();