Android application and read the web page - delphi

I have a question about the webbrowser component
Sow you change platform (mobile) devices note opens page
Display
Page Web note fond
Android path :Assets\internal\
thanks
EDIT: Code from comment
Var MS:tmemorystream;
Begin
Ms:=tmemorystream.create;
Ms.loadfromfile(gethomepath+pathdelim+'name.html');
Ms.postion:=0;
Ms.savetofile(opendilog .filename);
Webbrowser.navigate(opendilog.filename or 'name.html');
end;

assets\internal is not a path that your device can access. It's a path setting used by the deployment manager. To properly access that folder you must use
System.IOUtils.TPath.GetDocumentsPath
which points to the same folder that assets\internal points to.
The documentation for that is here http://docwiki.embarcadero.com/RADStudio/Rio/en/Standard_RTL_Path_Functions_across_the_Supported_Target_Platforms

Related

How to embed YouTube videos in newer versions of Delphi?

I'm trying to load a YouTube video into a TWebBrowser in Delphi XE7 and I'm getting an error that says this:
Adobe Flash Player or an HTML5 supported browser is required for video playback.Get the latest Flash Player
Learn more about upgrading to an HTML5 browser
I can load normal HTML just fine.
The examples I've found posted here earlier are for much older versions of Delphi, so I'm wondering if this is an issue with newer versions, or TWebBrowser, or something in my environment (VMWare 7 with Windows 7).
EDIT: My objective is simply to be able to load and play a video from a URL, like a YouTube video. Solutions other than TWebBrowser are fine, especially if they can run cross-platform.
You are wondering whether your problems relate to Delphi version. Well the WebBrowser control is a system control. Delphi version is not relevant because the service is provided by the underlying system. If anything has changed it is likely to be the way You Tube delivers videos.
If you are crafting the HTML that embeds the remote video then you should follow the latest documentation from You Tube as to how it should be done. Don't use years old Delphi specific articles as your guide. Use modern articles specific to the latest technology used by You Tube.
I do have a feeling, although you don't state so in the question, that you are using an old and possibly deprecated method to embed a You Tube video. Use an iframe as described here: http://www.w3schools.com/html/html_youtube.asp
Adobe Flash Player or an HTML5 supported browser is required for video playback.
Your WebBrowser control will, in the absence of you taking specific steps otherwise, be using a legacy IE browser engine. So it won't have HTML5 support. And perhaps not even Flash support, that is if You Tube is still prepared to serve videos as Flash. Nowadays HTML5 is preferred. Not least because modern browser support it out of the box and there is no need for third party Flash plugin installation.
One way to opt in to using a modern HTML5 browser with the WebBrowser control is to make explicit registry settings (browser feature emulation), and perhaps specify a DOCTYPE. More details here: How to have Delphi TWebbrowser component running in IE9 mode? Although that question specifically asks about IE9, the documentation links in the answer provide details for other IE versions.
If you don't have control over the HTML document then you will need to use the above method.
On the other hand, if you do control the content of the HTML document then there is another way. You can place this
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
as the first item in your page's <head>. The meaning of edge is the latest version of IE. If you wish to target a specific version, e.g. IE9 then you would use:
<meta http-equiv="X-UA-Compatible" content="IE=9" />
More info on this here:
https://msdn.microsoft.com/en-us/library/ms533876.aspx
https://www.modern.ie/en-gb/performance/how-to-use-x-ua-compatible
How to put the WebBrowser control into IE9 into standards?
Older versions of IE do not support this header and if you need to cater for them then you are back to browser feature emulation in the registry. Thanks to #whosrdaddy and #TLama in the comments, it seems that IE8 introduced support for X-UA-Compatible.
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

How to display local HTML text in blackberry using sdk 4.6

Till now i was using SDK 5.0 and was able to dispaly local html text using net.rim.device.api.browser.field2.BrowserField but now my requirement has changed and have to use SDK 4.6. The problem is that now i'm getting compiler error for the BrowserField. Can anyone help me in displaying HTML text in SDK 4.6
As there is no BrowserField class supported in earlier versions of RIM SDK, you can launch local browser session for a html file, embedded in your cod-application.
Let say your application cod name is mymodule.cod
And you have attached a document.html file to your project, and this file is located in your source code folder, not outside.
You can launch browser session via this code:
BrowserSession session = Browser.getDefaultSession();
session.displayPage("cod://mymodule/document.html" );
Note, that module name is case sensitive.
And note that it is not documented way to access local html files.
If you are going to test this in simulator, make sure that MDS simulator is launched and is working.
It is still possible to display local HTML content with the APIs available for earlier BlackBerry OS versions. It is just a bit more complicated to make it work. Doing this involves the older BrowserField API (as opposed to the newer BrowserField2 API you've already discovered). I think the SDK includes a "BrowserField" example app that partially demonstrates this. It involves using the RenderingSession class to retrieve a BrowserContent object, which has a method to return a UI Field that you can actually show within your screen.
The trick is that RenderingSession expects you to supply it with an HttpConnection (or InputConnection) that it can read the data from. Since these are interfaces, you just have to implement them in such a way they they return your own HTML data instead of wrapping an actual HTTP connection.
It may be a little specific to the context of my own application, but here is an example of a class I wrote that wraps this API for local HTML content display: BrowserFieldRenderer

Capturing folder path from Windows Explorer

I would like to add to a Delphi application a way for the user to call Windows Explorer (possibly using something like ShellExecute, perhaps).
However, and this is where I need some help, please, the application would need to capture ^H^H^H^H^H^H read the folder path that the user navigates to while within Windows Explorer.
Is it possible to obtain this information from Windows Explorer?
[edit: If not possible, or unrealistic, my fallback plan is to provide a separate "Browse for folder" button, to allow the user to select the folder first, then they can launch the Window explorer afterwards].
Thanks for any advice.
PhilW.
I dont know your exact needs, but most likely, this is not the way to go. For details, Microsoft developer Raymond Chen has written a blog post about this. What you should do, I think, is to embed an explorer browser control in a custom form in your own application.
For letting a user browse to and select a folder, I use TOrtusShellBrowseFolder.
Ortus Shell Components
Can't you just use the TOpenDialog? From Delphi Help:
Description
TOpenDialog displays a modal Windows dialog box for selecting and opening files. The dialog does not appear at runtime until it is activated by a call to the Execute method. When the user clicks Open, the dialog closes and the selected file or files are stored in the Files property.
if OpenDialog1.Execute then
filename := OpenDialog1.FileName;

How to retrieve the file previews used by windows explorer in Windows vista and seven?

I am developing a Delphi documents management application, so somehow I am giving the user some functionality similar to windows explorer.
I would like to know if there is a way to get the preview used by windows explorer. For example windows explorer creates a small thumbnail for a pdf document for example, and displays it when the user chooses to view "big icons". Is there a way to retrieve that preview?
MyTImage := GiveMePreviewForFile('C:\Test\File.pdf');
#user193655, using the IExtractImage interface is the way to go, this interface exposes methods that request a thumbnail image from a Shell folder
you can find a very complete sample in this site and the source code is here.
check this image
Take a look at the docs for IExtractImage. Basically you use IShellFolder with IExtractImage to get the picture you are looking for.

How Can I Automatically Execute A Link In Internet Explorer

I am trying to create an application to print documents over the web. I have created my document, and made a web page with a meta refresh tag, along the lines of this:
<meta http-equiv="refresh" content="3;http://example.com/download.epl2" />
I specify that the document has a content-type of application/x-epl2, and I have associated .epl2 files on my computer with a program that silently sends them to the printer.
I have put the website into my trusted sites zone.
Currently Internet Explorer pops up the "Open, Save, Cancel" dialog box with no option to automatically open the file.
Is there a setting in IE6/7/8 that I can use to have IE just open the file without prompting?
EDIT
The actual content of the file will differ based on the job, but essentially it is text that follows the Eltron Programming Language.
EDIT
I have accomplished this in both Chrome and Firefox by choosing "Automatically Open Files Of This Type From Now On"
EDIT
The machines this program will be used on will effectively be kiosks that are limited to only accessing my website from their web browsers, so I'm not worried about rogue websites sending documents to my printers.
EDIT
I am using PHP to generate the documents and HTML on the server side, though I expect the solution to be language agnostic.
I would expect that not to be possible, because then you could stumble onto a site that automatically loads and prints a 5000 page document or something, which would not be good.
If you always had a secret desire to develop a custom URL protocol (I know I do), this might be a good excuse to do it. ;-)
http://msdn.microsoft.com/en-us/library/aa767914%28VS.85%29.aspx
There are 1-2 prompts when opening such a link for the first time in IE, but you can choose to automatically open them after that.
I would use javascript to make this happen.
Javascript Window Open
EDIT
Since you have control of the windows box you could use an automate script process to interact with the print window.
autoit3: ControlClick
Write a small utility program that does nothing but send the file passed to it on the command-line to the default system printer.
Then, edit the registry under HKEY_CLASSES_ROOT to associate this program with the .epl2 filetype.
I don't have time to investigate it for You, but there were lots of exploits that could be helpful. Using ie6 without certain fixes seems helpful.
Also there should be an option called "Automatic prompting for file downloads". I use Linux nowadays so I can't chceck if it helps. I found it in some docs.
I'm on a Mac at the moment, but if this is possible in IE I would imagine this page holds the answer to it (or at least hints at it) http://support.microsoft.com/kb/883255
I believe what you're looking for is a setting in Windows, not IE:
Microsoft Support: Not Prompted to Specify Download Folder for File
Try using an older version of IE. Security was looser in the older versions and since it's a non-issue, this could be the quickest solution.

Resources