I am using YoutubeAPI to download Youtube videos of some channels(that gives me a permisson for it). I use https://youtube.googleapis.com/youtube/v3/videos to get embedhtml for video and I get it successfully.
Here is an example from StackOverflow's youtube channel (https://www.youtube.com/embed/HJtJXMKpl2g)
But the problems starts here. I use the code below to download some img or mp4 files normally in C#.
using (WebClient wc = new WebClient()) { wc.DownloadFileAsync( new System.Uri("https://www.youtube.com/embed/HJtJXMKpl2g"),"C:\\YoutubeTest\\yttestvideo.mp4" ); }
It actually downloads some file (probably broken) however it gives me error when I run it.
Windows Media Player cannot play. The player may not support the file content or the codec used to compress its files.
So how can I fix that or is there any other options to download video from youtube in C#?