none
How can I get YouTube video duration/length from C#?

    Question

  • Hello, i am trying to get the duration of a video for a project, but i don't know how to do it, i used an axshockwaveflashobject to watch the videos, but I can't know information of duration, current time, etc.. from C#, please help me, message me!
    Saturday, September 21, 2013 4:05 AM

Answers

All replies

  • Hi Fer,

    I am not fully sure about your issue, I think you can use Media.durationString. The durationString property retrieves a String value indicating the duration of the current media item in HH:MM:SS format.

    mediaDuration.Text = player.currentMedia.durationString;
    

    Of course, here is another example about how to get length of video:http://stackoverflow.com/questions/6215185/getting-length-of-video

    Thanks.


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, September 23, 2013 2:30 AM
  • Hello!

    Thanks for the reply, but i'm trying to get duration of YouTube videos, for instance: I put the url of the YouTube video and i click a button and i get the duration of that video, that´s what I´m trying to do, i had the idea to use Javascript in Webbrowser cause i think is the only way.

    Tuesday, September 24, 2013 12:02 AM
  • Hi Fer Mtz,

    I have done some search for you. There is a similar question about Get duration from a youtube url.

    You can use YouTube Data API to access most of the information about the video, including duration, the API enables your application to search for YouTube videos, upload videos to YouTube, and update existing videos. Your application can also retrieve playlists, subscriptions, favorite videos, and more. Finally, your application can submit authorized requests to enable users to create playlists and subscriptions, rate videos, add favorite videos, and perform other account-specific actions.https://developers.google.com/youtube/2.0/developers_guide_protocol?csw=1

    http://stackoverflow.com/questions/2086260/youtube-player-api-how-to-get-duration-of-a-loaded-cued-video-without-playing-i

    Thanks.


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    Tuesday, September 24, 2013 1:54 AM