1

Possible Duplicate:
Website screenshots using PHP

I have an application where people watch a stream of content (a video stream) and need to click a button each time something happens (suppose they see a red light).

I want to somehow screenshot the stream at the moment where the user clicks the button. The problem is that the stream is not mine and I am using an IFrame to another page with the stream. The stream is a flash object.

I need to screenshot the page at the moment of click with the flash content using PHP/Javascript and save it on the server.

I saw something that seems similar to what I need but the solution is using C# and .NET. Programmatically get a screenshot of a page

EDIT: Idea, if anyone can explain it best here, how could I do that using a plugin/java applet or something that the user might install when entering the site. (The easier the better).

Community
  • 1
  • 1
Vadiklk
  • 3,696
  • 5
  • 28
  • 44

3 Answers3

2

You can't get a screenshot client-side, and certainly not with PHP. PHP runs on your server, not on the client.

The only way to do this would be to write a browser plugin of some sort, or utilize Java.

See this post: Take Screenshot of Browser via JavaScript (or something else)

Community
  • 1
  • 1
Brad
  • 159,648
  • 54
  • 349
  • 530
  • Yes, but maybe there is a way to using my server access the page and screenshot it. – Vadiklk Jan 28 '12 at 20:46
  • @Vadiklk, How do you plan on doing that? Your server can render pages, sure, but they may look entirely different than what the client sees, and certainly at not any specific time. – Brad Jan 28 '12 at 20:46
  • The time is specific, when the user clicks the button. On the click I send a request to the server using AJAX which I then want to save the screenshot. – Vadiklk Jan 28 '12 at 20:48
  • Right. How do you plan on getting a screenshot **from the client**? – Brad Jan 28 '12 at 20:49
  • I don't want to save the screenshot from the client, I just want the click to indicate to the server using AJAX that he needs to access the page now and save a screenshot. – Vadiklk Jan 28 '12 at 20:54
  • But, you want a screenshot of that particular point in time, of a video, right? You realize that video playback is not synchronized across all clients? It isn't uncommon for "live" streaming video to be off by one minute or more. – Brad Jan 28 '12 at 20:55
  • I've edited the question. I like the link that you gave, but could explain better what the user there tried to explain? – Vadiklk Jan 28 '12 at 21:00
  • A screenshot from Javascript wouldn't contain the video regardless, since it came from another domain. Being able to view it would be a violation of the same-domain origin policy. – Borealid Jan 28 '12 at 21:17
0

After a request to view your website has been made by a browser, your PHP code is run and generates the content of the page. By the time your user sees the page, the PHP has finished running, and the content of the page is static as far as that is concerned (although of course can be changed by other means, like ajax or javascript).

That's why this isn't possible at all with PHP, and it's not possible by another means for security reasons (for example, it could reveal any client-side scripts the user is running, etc.).

The only way a screenshot could be taken would be to render it yourself. The only way I can think of offhand would be to get the time on loading of the page, then the time when the button is pressed, and render the page for this long, but this is by no means foolproof and not really a valid suggestion.

I'm afraid that you'll probably have to redesign this portion of your site.

Swadq
  • 1,837
  • 2
  • 15
  • 25
  • Well, embed your website into a java applet and add a jbutton. When the button's pressed, take a screenshot and e-mail it to yourself. – Swadq Jan 28 '12 at 21:13
0

Since you say that the stream is a Flash object, you could simply read it into a Flash enviroment. Flash would allow you to do what you want - saving screenshots, or, better said, images generated by that Flash, i.e. still frames. However, I am not sure if Flash would allow you to make a screenshot of the display incl the OS enviroment.

Michal
  • 3,262
  • 4
  • 30
  • 50