As stated before I belive using TWebBrowser is the wrong way arround, because you have to little control about you video. Because then you have control over the video playback you self.
*** NOTE ****
DIRECT streaming of YouTube videos breaks the terms of service
*** NOTE ****
As i prommised you I've made an example here of howto play a youtube video on a Wincontrol ex. TPanel.
Since the example includes code for parsing the youtube URL and code for parsing the sourcecode of the youtube page where the video is embedded I can not post the complete source code here. And you have to get it from this link here
I'll here go trough the main idea of my exampel.
first a screenshot of the final result:

The first thins to is are to import the WindowsMediaPlayer system component (not to be confused with the one ships with Delphi) and save WMPLib_TLB.pas alon with the project source.
Next step is do declare a private instance of the class:
WindowsMediaPlayer: TWindowsMediaPlayer;
And in formCreate, create an instance af set it up:
procedure TMainform.FormCreate(Sender: TObject);
begin
WindowsMediaPlayer := TWindowsMediaPlayer.Create(Panel2);
WindowsMediaPlayer.Parent := Panel2;
WindowsMediaPlayer.Align := TAlign.alClient;
WindowsMediaPlayer.Visible := True;
WindowsMediaPlayer.Settings.AutoStart := True;
WindowsMediaPlayer.uiMode := 'none';
with TYoutubeThread.Create('https://www.youtube.com/watch?v=7vkYiCdn834') do
OnTerminate := YoutubeThreadTerminate;
end;
Next step is to create an TYoutubeThread
. TYoutubeThread
is a thread that will get the HTML sourcocode of the requested youtubepage and parse it in order to get the information about the embedded video. The sourcecode for this thread are to be found in the complete example.
When the thread terminates we need to setup the GUI :
procedure TMainform.YoutubeThreadTerminate(Sender: TObject);
var
YoutubeThread: TYoutubeThread;
begin
YoutubeThread := Sender as TYoutubeThread;
if YoutubeThread = nil then
exit;
//The information list are sorted my number of pixels in the video
FInformation := YoutubeThread.Youtube.Informations.Last;
Caption := Format('%s %s (%dx%d)', [YoutubeThread.Youtube.Title, FInformation.Quality, FInformation.Size.cx, FInformation.Size.cy]);
Panel1.Visible := True;
Width := FInformation.Size.cx + 50;
Height := FInformation.Size.cy + Panel1.Height + 50;
WindowsMediaPlayer.URL := FInformation.VideoLink;
TrackBar1.Max := 0;
end;
Ive omitted two units, they can be downloded here http://pastebin.com/TqCUV9tg
and here http://pastebin.com/WFGctwrf. And you'll lso need a copy of SuperObject
Or you could download the complete working example here