FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » detecting a file in use
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
detecting a file in use [message #183648] Wed, 06 November 2013 17:12 Go to next message
Mr Oldies is currently offline  Mr Oldies
Messages: 241
Registered: October 2013
Karma: 0
Senior Member
What should be used to know when a request has been made for the server to
load an audio file?
As I see it, the server has to know that a request has been made.

You, the user, using your browser, sees a list of songs that you can play.
You click that link, the browser sends a request to fetch that file.
This is the point in time when I want to know that the request has been
made.
Javascript takes care of the playing side.
But still, the server has to have some way of knowing which audio file is
being requested and whether or not buffering is needed.

Now that the audio file has played, the server needs to know that file has
completed downloading.
So what do I use to know this has happened?
Re: detecting a file in use [message #183649 is a reply to message #183648] Wed, 06 November 2013 17:34 Go to previous messageGo to next message
J.O. Aho is currently offline  J.O. Aho
Messages: 194
Registered: September 2010
Karma: 0
Senior Member
On 06/11/13 18:12, richard wrote:
> What should be used to know when a request has been made for the server to
> load an audio file?
> As I see it, the server has to know that a request has been made.
>
> You, the user, using your browser, sees a list of songs that you can play.
> You click that link, the browser sends a request to fetch that file.
> This is the point in time when I want to know that the request has been
> made.

three ways to do it

Simple: parse the log file
Medium: use a wrapper file which notify that someone requested a file
and then serve the file, this can destroy fast
forward/rewind/pause/resume features.
Complicated: Make the JavaScript to call a page and tell which file the
user is loading and if they do buffer or not.

> Javascript takes care of the playing side.
> But still, the server has to have some way of knowing which audio file is
> being requested and whether or not buffering is needed.


> Now that the audio file has played, the server needs to know that file has
> completed downloading.
> So what do I use to know this has happened?

If you use wrapper and the page terminates, then it's finished with the
download. If you use the javascript then make an ajax call and tell that
the song has finished to play.

--

//Aho
Re: detecting a file in use [message #183650 is a reply to message #183648] Wed, 06 November 2013 17:36 Go to previous messageGo to next message
Tobiah is currently offline  Tobiah
Messages: 30
Registered: April 2011
Karma: 0
Member
On 11/06/2013 09:12 AM, richard wrote:
> What should be used to know when a request has been made for the server to
> load an audio file?
> As I see it, the server has to know that a request has been made.
>
> You, the user, using your browser, sees a list of songs that you can play.
> You click that link, the browser sends a request to fetch that file.
> This is the point in time when I want to know that the request has been
> made.
> Javascript takes care of the playing side.
> But still, the server has to have some way of knowing which audio file is
> being requested and whether or not buffering is needed.
>
> Now that the audio file has played, the server needs to know that file has
> completed downloading.
> So what do I use to know this has happened?
>

What you probably want is to use a PHP script that is masquerading as
the audio file. You can make a directory called 'my_song.wav', and have
an index.php inside that directory. At least with Apache, it will detect
the directory and instead load the index.php file. Your PHP code in that file can
introspect it's request with $PHP_SELF and find out what song was asked
for. Then, you can fopen() the real audio file (could be a sibling of
index.php, or in some other audio directory), and print it out to the
browser. Now your are in PHP, and you know that the request for the
song has been made. You won't be able to tell when the song
has finished, because there will be output buffering going on.

You may be able to do ob_start() before you print the .wav content,
then when you do ob_end_clean(), I would guess that when that statement
has finished you at least know that the server is done sending the
audio content. That still doesn't guarantee that the user has heard the
end of the song on their end however.


Tobiah
Re: detecting a file in use [message #183651 is a reply to message #183648] Wed, 06 November 2013 17:36 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 06/11/13 17:12, richard wrote:
> What should be used to know when a request has been made for the server to
> load an audio file?
> As I see it, the server has to know that a request has been made.
>
> You, the user, using your browser, sees a list of songs that you can play.
> You click that link, the browser sends a request to fetch that file.
> This is the point in time when I want to know that the request has been
> made.
> Javascript takes care of the playing side.
> But still, the server has to have some way of knowing which audio file is
> being requested and whether or not buffering is needed.
>
> Now that the audio file has played, the server needs to know that file has
> completed downloading.
> So what do I use to know this has happened?
>
YOU don't.
The operating system knows, because the IP connection has (probably)
gone. The file may or may not remain in cache depending on how much RAM
the server has, and how busy it is.


--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
Re: detecting a file in use [message #183653 is a reply to message #183648] Wed, 06 November 2013 18:01 Go to previous message
Luuk is currently offline  Luuk
Messages: 329
Registered: September 2010
Karma: 0
Senior Member
On 06-11-2013 18:12, richard wrote:
> What should be used to know when a request has been made for the server to
> load an audio file?
> As I see it, the server has to know that a request has been made.
>
> You, the user, using your browser, sees a list of songs that you can play.
> You click that link, the browser sends a request to fetch that file.
> This is the point in time when I want to know that the request has been
> made.
> Javascript takes care of the playing side.
> But still, the server has to have some way of knowing which audio file is
> being requested and whether or not buffering is needed.
>
> Now that the audio file has played, the server needs to know that file has
> completed downloading.
> So what do I use to know this has happened?
>

You need to have a basic understanding of the HTTP-protocol.
This is (i think it is) considered off-topic in comp.lang.php

Maybe microsoft.public.winhttp is a good place to ask?
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: accessing nested unknown unserialized objects
Next Topic: detection of 2d array?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 02:10:47 GMT 2024

Total time taken to generate the page: 0.01930 seconds