RobYost Posted September 29, 2017 Share Posted September 29, 2017 I have a procedure that works at playing Youtube videos. But it only works if you are on the same computer as the UniGUI program that is running.l I put it on my server and when on the server it works, but if I try from across the internet it does not. Is there a port that needs to be opened? (Video is a TUniHTMLFrame) procedure TfrmModal.ShowVideo(VideoName: string; VideoWidth: Integer; VideoHeight: Integer); var sql: TSQL; begin frmModal.Height := VideoHeight + GetSystemMetrics(SM_CYCAPTION); frmModal.Width := VideoWidth; sql.Add('<html>'); sql.Add('<head>'); sql.Add('</style>'); sql.Add(' <style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style>'); sql.Add('</head>'); sql.Add('<body>'); sql.Add(' <object width="' + itoa(VideoWidth) + '" height="' + itoa(VideoHeight) + '">'); sql.Add(' <param name="movie" value="http://www.youtube.com/v/fqNHsmGCEDI&hl=en_US&feature=player_embedded&version=3">'); sql.Add(' </param><param name="allowFullScreen" value="true">'); sql.Add(' </param><param name="allowScriptAccess" value="always">'); sql.Add(' </param><embed src="http://www.youtube.com/v/' + VideoName + '&hl=en_US&feature=player_embedded&version=3" type="application/x-shockwave-flash" sql.Add('');allowfullscreen="true" allowScriptAccess="always">'); sql.Add(' </embed></object>'); sql.Add('</body>'); sql.Add('</html>'); Video.Align := alClient; Video.Enabled := True; Video.HTML.Clear; Video.HTML.Add(sql.Text); end; Quote Link to comment Share on other sites More sharing options...
RobYost Posted September 29, 2017 Author Share Posted September 29, 2017 I just noticed I used a Type that I wrote: TSQL I created it so I wouldn't have to create and free TStringList, and the text property is useful when debugging 'Copy Value' does not have any CR LF in it so I can paste it to SQL Server. You can replace the TSQL with TStringList (but you have to create it) I will include the TSQL Source if anyone is interested in it. Let me know if you see a problem with it. type TSQL = record private FItems: array of string; FText : String; function GetCount: integer; inline; function GetText: String; inline; function GetItem(index: integer): string; procedure SetItem(index: integer; const Value: string); public property Text : string read GetText; property Count: integer read GetCount; function Add(const line: string): integer; procedure Clear; function IndexOf(const s: string): integer; property Items[index: integer]: string read GetItem write SetItem; default; end; // ============================================================================= function TSQL.Add(const line: string): integer; begin SetLength(FItems, Count + 1); FItems[Count - 1] := line; Result := Count - 1; FText := Text; end; // ============================================================================= function TSQL.GetCount: integer; begin Result := length(FItems); end; // ============================================================================= function TSQL.GetText: String; var i: integer; begin for i := 0 to Count - 1 do Result := Result + ' ' + FItems[i]; end; // ============================================================================= procedure TSQL.Clear; begin SetLength(FItems, 0); end; // ============================================================================= function TSQL.GetItem(index: integer): string; begin Result := FItems[index]; end; // ============================================================================= procedure TSQL.SetItem(index: integer; const Value: string); begin FItems[index] := Value; end; // ============================================================================= function TSQL.IndexOf(const s: string): integer; var k: integer; begin Result := -1; for k := 0 to Count - 1 do begin if FItems[k] = s then begin Result := k; break; end; end; end; Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 29, 2017 Share Posted September 29, 2017 Hi, Maybe other stations do not have a plugin ?.. And YouTube <object> and <embed> were deprecated from January 2015. You should migrate your videos to use <iframe> instead. https://www.w3schools.com/html/html_youtube.asp Best regards, Quote Link to comment Share on other sites More sharing options...
RobYost Posted October 5, 2017 Author Share Posted October 5, 2017 I determined that it worked if I used HTTP but not HTTPS. BUT after not getting it to work, I made a small test program to show to Delphi Developer. In the test program I changed it from <embed> to <iframe> like he said and it worked. So he gave me the answer all along and I didn't try it because I could get it to work on my computer. Once again Delphi Developer came through with the answer. Just trust him. 1 Quote Link to comment Share on other sites More sharing options...
linehammer Posted May 30, 2019 Share Posted May 30, 2019 Upload the video to YouTube Take a note of the video id Define an <iframe> element in your web page Let the src attribute point to the video URL Use the width and height attributes to specify the dimension of the player Add any other parameters to the URL Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.