URLからのみYouTubeビデオを再生する機能コードがあります(youtube.com/watch?v=....など)。この記事から使用しました。ただし、短縮 URL (youtu.be/.... など) では機能しません。両方の方法でそれを行うことは可能ですか?
Protected Sub SetVideoForPlay()
'YouTube Video URL
Dim youtubeUrl As String = "http://www.youtube.com/watch?feature=endscreen&v=gfedwjAOMZI&NR=1"
Dim vCode As String = youtubeUrl.Substring(youtubeUrl.LastIndexOf("v=") + 2)
If vCode.Contains("&") Then
vCode = vCode.Substring(0, vCode.LastIndexOf("&"))
End If
Dim sHtml As String = "<object width='{0}' height='{1}' data='http://www.youtube.com/v/{2}&autoplay=0' codetype='application/x-shockwave-flash'>" & vbCr & vbLf & " <param name='movie' value='http:// www.youtube.com/v/{2}&autoplay=0'></param></object>"
'define frame size
Dim sWidth As String = "500px"
Dim sHeight As String = "500px"
'insert code to the Div
divVideo.InnerHtml = [String].Format(sHtml, sWidth, sHeight, vCode)
End Sub