<Window x:Class="ErasmusWPF.Marta"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ErasmusWPF"
mc:Ignorable="d"
Title="Marta" Height="768" Width="1366" ResizeMode="NoResize" WindowState="Maximized" AllowsTransparency="True" WindowStyle="None" Background="Transparent">
<Grid>
<Image Source="Images\grass.jpg" Stretch="UniformToFill" Grid.ColumnSpan="2"/>
<Image Source="Images\rail_luxury_shift-a.png" Height="833" VerticalAlignment="Bottom" OpacityMask="Black" Margin="-717,-38,-862,-27" Grid.ColumnSpan="2"/>
<Image Source="Images\Untitled.png" Margin="234,0,-369,-125" Width="1400" Height="767.8"/>
<TextBlock x:Name="textBlock" HorizontalAlignment="Left" Margin="636,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="566" LineHeight="18" TextAlignment="Center" FontSize="30"><Run Text="Klausīties Valka mūziku "/><LineBreak/><Run Text="(""/><Run Text="Dis"/><Run Text="t"/><Run Text="a"/><Run Text="nt Light")"/><LineBreak/><Run Text=" "/><InlineUIContainer/></TextBlock>
<Button x:Name="button5" Content="" Margin="636,27,624,682" Click="button_Click">
<Button.Background>
<ImageBrush ImageSource="Images/bcyEgxxzi.png"/>
</Button.Background>
</Button>
<Button x:Name="play" HorizontalAlignment="Left" Margin="484,322,0,0" VerticalAlignment="Top" Width="140" Height="84" Click="play_Click" >
<Button.Background>
<ImageBrush ImageSource="Images/playbutton.png"/>
</Button.Background>
<MediaElement x:Name="mediaElement" HorizontalAlignment="Left" Height="84" VerticalAlignment="Top" Width="140" LoadedBehavior="Manual" UnloadedBehavior="Stop" Source="C:\Users\Leonards\Documents\Visual Studio 2015\Projects\ErasmusWPF\ErasmusWPF\ayylmao\crysis3.wmv" RenderTransformOrigin="0.5,0.5" Stretch="Fill" >
</MediaElement>
</Button>
<Button x:Name="play2" HorizontalAlignment="Left" Margin="669,322,0,0" VerticalAlignment="Top" Width="140" Height="84" Click="play2_Click" >
<Button.Background>
<ImageBrush ImageSource="Images/playbutton.png"/>
</Button.Background>
</Button>
<MediaElement x:Name="mediaElement2" HorizontalAlignment="Left" Height="768" VerticalAlignment="Top" Width="1368" LoadedBehavior="Manual" UnloadedBehavior="Stop" Source="C:\Users\Leonards\Documents\Visual Studio 2015\Projects\ErasmusWPF\ErasmusWPF\ayylmao\crysis3.wmv" Margin="0,0,-2,0" Stretch="Fill" />
</Grid>
</Window>
这是我的xaml代码
public Marta()
{
InitializeComponent();
}
private void button_Click(object sender, RoutedEventArgs e)
{
System.Media.SoundPlayer player =
new System.Media.SoundPlayer();
player.SoundLocation = @"C:\Users\Leonards\Documents\visual studio 2015\Projects\ErasmusWPF\ErasmusWPF\Music\DistantLight.wav";
player.Load();
player.Play();
}
private async void play_Click(object sender, RoutedEventArgs e)
{
mediaElement.Play();
await Task.Delay (183000);
mediaElement.Source = null;
}
private async void play2_Click(object sender, RoutedEventArgs e)
{
mediaElement2.Play();
await Task.Delay(183000);
mediaElement2.Source = null;
}
}
当我尝试在任何其他计算机上运行应用程序时,问题就开始了。 Mediaelements是为我的计算机C目录编程的。无论何时在任何其他电脑上闲逛,内容都会丢失并丢失。