In this topics I will discus about "How to get YouTube video id from its URL". For this create a simple javascript function as bellow -
|
| |
| function YouTubeGetID(url){ |
| var ID = ''; |
| url = url.replace(/(>|<)/gi,'').split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/); |
| if(url[2] !== undefined) { |
| ID = url[2].split(/[^0-9a-z_\-]/i); |
| ID = ID[0]; |
| } |
| else { |
| ID = url; |
| } |
| return ID; |
| }
|
Call the function as bellow -
|
| var youtubeurl="https://www.youtube.com/watch?v=_Yt9Xfo4VN4"; |
| YouTubeGetID(youtubeurl); |
And then you will get something output for example url as bellow -
I hope it will helpful for you.
Now it's time for enjoy.
For any comment or suggestion on this topics, please mention your comment on comment box bellow.
Its a wonderful post and very helpful, thanks for all this information.
ReplyDeleteJavascript Course
Thank you for sharing nice blog
ReplyDeletee accounting course in uttam nagar
Thank you for sharing nice blog
ReplyDeletePrivate School in Pali