0
Hi,
I am searching for the following possiblities for the Music Collection
- counting the number of downloads for each song
- counting how often a song has been listened
Is there an existing extension which does these jobs?
Or can someone tell me where I can implement it by myself (which php file do I have to change / extend)?
Maybe it is possible instead of counting the hits (column "hits" in database).
I can implement it myself if it does not exist yet but I need some help where?
Thanks for the help in advance!
Michael
I am searching for the following possiblities for the Music Collection
- counting the number of downloads for each song
- counting how often a song has been listened
Is there an existing extension which does these jobs?
Or can someone tell me where I can implement it by myself (which php file do I have to change / extend)?
Maybe it is possible instead of counting the hits (column "hits" in database).
I can implement it myself if it does not exist yet but I need some help where?
Thanks for the help in advance!
Michael
Responses (6)
-
Accepted Answer
-
Accepted Answer
0Thanks for the answer! That helps me a lot.
How can I implement the counting of listens by myself? In which module / php-file can I "catch" the event if a user clicks on the "Play" button?
Background information:
I want to realize two music charts for the songs:
- top downloaded songs
- top listened songs
Would be great if you can give me a hint -
Accepted Answer
0germi wrote:
Number of downloads is already stored in the songs table, on the downloads field
Number of listens cannot be stored in this version of MC
In the storage of the number of downloads there is a bug:
If I download ONE song the downloaded column is incremented for ALL songs. But normally it should be incremented only for the downloaded song. Maybe you can send me a fix!? -
Accepted Answer
01) well... this is way difficult. I asume you're a good programmer, so I will be a bit technical:
since the URL of the song is a direct link, there's no way to know when the player requests a file url, because it does not goes thorugh any PHP script.. its direct (this is different than the download: the download its not direct, it goes through a php script, wich is the one who performs the taks of increasing the counter on the database field)
so, initially, the first though is that THERES NO WAY TO DO IT, because there's no script that handles the song playing!!
HOWEVER: I think JWPLAYER (not sure from which version) has a functionallity to CALL A FUNCTION whenever a song ends (or starts, I guess) playing. in other words, I believe that you can somehow add an "event listener" on the jwplayer, and associate it to your custom function.
I never used this, and dont know how it works. so, I just can point to the right direction. the best thing you can do is to go to their page (longtail.com) and search there. there's a good documentation.
try to search for "jwplayer javascript events" or something like that
in case you discover how to do it and you actually get to ahve your JS function called when a song ends playing.. well, in that case, BIG HURRAfor you, the rest should be "easy" for you (*easy* if you know joomla programming...):
all you have to do is to make this JS function call, using AJAX, a PHP script that will increase the song's number of listens counter on the songs database. you need to add a "listens" counter field on the database table first, of course.
did you understand?I hope you did
UPDATE: I've just readed better your post, and there's a easiest way for the first part: the method I described is actually more accurated because it really fires the event when the song ENDS playing.
but YES, its MUCH easier if you just increase the counter when the users clicks on play (altoguh he maybe wont play it completely)
as you can see, the play button calls
javascript:album_player.sendEvent('ITEM',0);
WHERE: the second parameter is the position of the item to play in the playlist.
this code is written on plugins/muscolplayers/jwplayer.php on line 139
well, you will just have to replace it for something like:
javascript
laysong(0, 1234);
(first param: order of the song on the playlist, just as before. second one: the id of the song.)
and, of course, define your playsong function:
function playsong(order, song_id){
album_player.sendEvent('ITEM',order);
increase_song_counter(song_id);
}
(this is basically a wrapper for the "sendEvent" function, but calls your custom function to allow increase counter
and then, last but not least..
function increase_song_counter(song_id){
// your code, basically an AJAX call to some URL, passing the song_id as a parameter, to increase the song listens counter
}
MAKES SENSE? -
Accepted Answer
0ooom wrote:
germi wrote:
Number of downloads is already stored in the songs table, on the downloads field
Number of listens cannot be stored in this version of MC
In the storage of the number of downloads there is a bug:
If I download ONE song the downloaded column is incremented for ALL songs. But normally it should be incremented only for the downloaded song. Maybe you can send me a fix!?
Here is the bugfix for the wrong couting the downloads, I corrected it in model file.php, function &getData():
Wrong line:
$query = ' UPDATE #__muscol_songs SET downloaded = '. ( $this->_data->downloaded + 1 ) ;
Corrected line:
$query = ' UPDATE #__muscol_songs SET downloaded = '. ( $this->_data->downloaded + 1 ) . ' WHERE id = '.$this->_id;
-
Accepted Answer
Your Reply

Please login to post a reply
You will need to be logged in to be able to post a reply. Login using the form on the right or register an account if you are new here.
Register Here »