-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Play a video on WPF #9127
Comments
@phanthanhdat077 can you please provide your sample app and we can check and update if there is something? |
1.Make sure the video link is accessible Local video link: The video can be opened locally and the link location is correct I can't display the video link you gave me. Maybe it's a problem with the video. You can try a few more video links.
<Grid Loaded="UserControl_Loaded">
<MediaElement x:Name="mediaElement" />
</Grid>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
// Bind video files
mediaElement.Source = new Uri([https://prod-streaming-video-msn-com.akamaized.net/a8c412fa-f696-4ff2-9c76-e8ed9cdffe0f/604a87fc-e7bc-463e-8d56-cde7e661d690.mp4](https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fprod-streaming-video-msn-com.akamaized.net%2Fa8c412fa-f696-4ff2-9c76-e8ed9cdffe0f%2F604a87fc-e7bc-463e-8d56-cde7e661d690.mp4&data=05%7C02%7Cv-huiliu1%40microsoft.com%7C70ca5a2e4bc84bf5f5fc08dc78b37fbd%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638517959546117408%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=aY0a8VfftilvsgCnGNmDYVUKPeMR96GuK3Bf8nfpH0I%3D&reserved=0));
// Allow interactive control
mediaElement.LoadedBehavior = MediaState.Manual;
mediaElement.Loaded += new RoutedEventHandler(media_Loaded);
mediaElement.Unloaded += new RoutedEventHandler(media_Unloaded);
mediaElement.MediaEnded += new RoutedEventHandler(media_MediaEnded);
}
private void media_Loaded(object sender, RoutedEventArgs e)
{
(sender as MediaElement).Play();
}
private void media_Unloaded(object sender, RoutedEventArgs e)
{
(sender as MediaElement).Stop();
}
private void media_MediaEnded(object sender, RoutedEventArgs e)
{
(sender as MediaElement).Stop();
(sender as MediaElement).Play();
}
} |
I'm learning WPF and trying to make a Chat project and am having problems playing videos in WPF.I try with MediaElement but it slow and can not play a video from link : "https://beta.api.gateway.overate-vntech.com/s3/techres/keep/2024/05/18/videos/original/overate-vntech-37342-Bc33OhaNuCvJ8Xg8s5868.mp4" . Please someone help me about it! How can play a video on WPF like:
The text was updated successfully, but these errors were encountered: