| Author |
Controlling the number of times the user can watch a video
|
Reham Omar
Greenhorn
Joined: Sep 06, 2006
Posts: 12
|
|
Dear All, I have an HTML page with an embedded video.And I want to control the number of times the user can watch this video, for example for only 3 times. How can i do this ?? Best Regards, Reham
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
It depends on your definition of "the user". Can you tell us what you mean by user?
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
Really needs to be controlled at a server level. JavaScript has no real way of preventing this. Eric
|
 |
Reham Omar
Greenhorn
Joined: Sep 06, 2006
Posts: 12
|
|
|
The user is the one watching the video (using the HTML). I mean i want the viewer to be able to press play twice only then it is disabled.
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16482
|
|
Originally posted by Reham Omar: The user is the one watching the video (using the HTML). I mean i want the viewer to be able to press play twice only then it is disabled.
So if a second person walked up to the computer, you would want the play button to be enabled again so that the second person could watch the video?
|
 |
Reham Omar
Greenhorn
Joined: Sep 06, 2006
Posts: 12
|
|
No, Assuming only one user per computer, This user(using the HTML) can only watch the viedo a certain number of times(for example 2 ). He can not keep pressing the play button and watch it any number of times. Sorry for not being specific. [ April 21, 2007: Message edited by: Reham Omar ]
|
 |
Hussein Baghdadi
clojure forum advocate
Bartender
Joined: Nov 08, 2003
Posts: 3359
|
|
As Eric said, that needs to be controlled at a server level. For example, let the user logs in and then you can control activity.
He can not keep pressing the play button and watch it any number of times.
Well, I'm not the best person to talk about JavaScript but I think you can employ it here. But JavaScript here alone is useless with the required server side logic.
|
 |
Reham Omar
Greenhorn
Joined: Sep 06, 2006
Posts: 12
|
|
Even if the user is logged and from the servlet i checked that that user can only watch it 2 times, how can this be handled in the server, I still can not get the picture !!
|
 |
Hussein Baghdadi
clojure forum advocate
Bartender
Joined: Nov 08, 2003
Posts: 3359
|
|
Reham, I'm not sure I got what you mean. More details please.
|
 |
Reham Omar
Greenhorn
Joined: Sep 06, 2006
Posts: 12
|
|
|
For example, we are in a listening test, i want the person taking the exam to be able to listen the the question only 2 times but not more.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56166
|
|
That all greatly depends upon what kind of controls you are using on the page to start the video/sound. Is it possible to get an event notification when the "Play" button is pressed? If so, perhaps you could make an Ajax request to the server that asks "permission" to proceed. The server would keep track of things in the session. It'd be important to make sure that the state persists across page loads so that a Refresh doesn't reset any coutners and so on...
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Reham Omar
Greenhorn
Joined: Sep 06, 2006
Posts: 12
|
|
That all greatly depends upon what kind of controls you are using on the page to start the video/sound. Is it possible to get an event notification when the "Play" button is pressed?
Well I do not understand what you mean by this ? And how i can get this event ??
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56166
|
|
Originally posted by Reham Omar: And how i can get this event ??
That is, indeed, the million-dollar question. Without knowing a great deal more about how you are playing the video/sounds, no one can say.
|
 |
Reham Omar
Greenhorn
Joined: Sep 06, 2006
Posts: 12
|
|
I am playign the video using this code Is there i was to disable the controls of the media player after pressing on play for two times. I am not sure if this is the correct way to be able to play and stop the video a certain number of times but I do not know anyway!
|
 |
Roger F. Gay
Ranch Hand
Joined: Feb 16, 2007
Posts: 334
|
|
You could put the object in a div and in response to maximum number of tries completed, set div_id.innerHTML =""; On each click, simply test if div_innerHTML = ""; If you don't like innerHTML, use getElementById(div_id).
|
Correlation does not prove causality.
|
 |
Reham Omar
Greenhorn
Joined: Sep 06, 2006
Posts: 12
|
|
Originally posted by Roger F. Gay: You could put the object in a div and in response to maximum number of tries completed, set div_id.innerHTML =""; On each click, simply test if div_innerHTML = ""; If you don't like innerHTML, use getElementById(div_id).
My problem is how will i find the maximum number of tries? How will I know that the user pressed the play button twice ?? I am sorry for asking too much but I do not know how to do this.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56166
|
|
|
You're obviously using a browser plugin to play the video. You'll need to learn more about the plugin and how it works in order to find out if it has the hooks you need to accomplish what you are attempting.
|
 |
Roger F. Gay
Ranch Hand
Joined: Feb 16, 2007
Posts: 334
|
|
Originally posted by Reham Omar: My problem is how will i find the maximum number of tries? How will I know that the user pressed the play button twice ?? I am sorry for asking too much but I do not know how to do this.
If you can call a javascript function in response to the click, and let the javascript function trigger audio, you can also have it keep count of the number of times the audio has been requested. How simple that is depends on how much you want to keep track of and for how long. If you just want to know whether a button has been clicked twice in one page (that is not being reloaded); ++count; ... if (count >= max_clicks) ... The problem that page loading would reset things, means that you have to come up with a way to disallow reloading or to keep track of clicks number of clicks outside the page so that reloading wouldn't matter. If you do either of those things in javascript, it still might not solve all your problems though. What happens if there's a problem with the audio, and the user doesn't really get to hear it even though they've requested it? Is there feedback from the audio plug-in that can report back to your page? Now ... that's moving back toward depending on processes not in the web page. But you asked ... and this is just a suggestion about something that can be done in javascript. [ April 22, 2007: Message edited by: Roger F. Gay ]
|
 |
Roger F. Gay
Ranch Hand
Joined: Feb 16, 2007
Posts: 334
|
|
One approach to guard against reload: <html> <head> <script type="text/javascript"> function setchange () { window.onresize=change(); } function change () { document.location = "reload3.htm"; } </script> </head> <body> This is no. 2 <input type="submit" value="click" onclick="javascript:void(setchange())" /> </body> </html>
|
 |
 |
|
|
subject: Controlling the number of times the user can watch a video
|
|
|