0
Hi Germi,
I'm trying to integrate tracking of plays inside of music collection with my facebook application. I'm over half-way there in the sense that I have a basic function working. In order to complete it I have a couple of questions relating to which files I would need to edit...
What I've done
To test that the basics of this work, I have written a bit of custom javascript that sends a facebook event to my facebook application whenever a user clicks the play button on a playlist item (album page for example). For example, in facebook app, a post is created saying "[Username] listened to [track name] on LearnThruSong" and includes artwork, description etc.
At the moment, I have this working with the following edit to the play_song_position function in the /plugins/muscolplayers/jwplayer/playlist_functions.js file. As you can see, this has been achieved by introducing an additional url parameter/variable (the url to the song) being passed to the function in the on click.
Edit of the play_song_position function
Note, this works because I have setup the facebook OpenGraph tags on each album/song pages that are required to use the content in the context of facebook/opengraph objects.
Now that I know that this process works, I wish to develop this further so that it works for plays on songs, song, playlists and album views & the module where;
[ol]
[li]In album/playlists and songs, I want the event to trigger not just on the play button, but also, when the next song(s) are played automatically. E.g. If I click play on an album page and listen to the whole album, I want to trigger the same event after each song has finished.[/li]
[li]In song pages (single player), clicking the player's play button triggers the same facebook event.[/li]
[/ol]
In each case, I only want the event to trigger when an entire song has been played or maybe, when it has reached the middle of the song, I will trigger a dialog box asking if the user wishes to share this song.
Given that muscol/jwplayer already have listeners/events that are being used to track plays, I should be able to add the same type of edit above to the the JS files, right?
Could you please advise me which files/functions I will need to edit in order to make this work?
Naturally, I'd be completely happy to share the entire working code if you wish, including the custom integration that I've written for JFBConnect that dynamically writes facebook's OpenGraph tags for album/artist/song pages.
Many thanks in advance!
Gez
I'm trying to integrate tracking of plays inside of music collection with my facebook application. I'm over half-way there in the sense that I have a basic function working. In order to complete it I have a couple of questions relating to which files I would need to edit...
What I've done
To test that the basics of this work, I have written a bit of custom javascript that sends a facebook event to my facebook application whenever a user clicks the play button on a playlist item (album page for example). For example, in facebook app, a post is created saying "[Username] listened to [track name] on LearnThruSong" and includes artwork, description etc.
At the moment, I have this working with the following edit to the play_song_position function in the /plugins/muscolplayers/jwplayer/playlist_functions.js file. As you can see, this has been achieved by introducing an additional url parameter/variable (the url to the song) being passed to the function in the on click.
Edit of the play_song_position function
function play_song_position(position,song_url){
album_player.playlistItem(position);
// Gez added
var song_link = "/me/learnthrusong:listen?song=" + song_url;
//alert(song_link);
// Send event to facebook
FB.api(
song_link,
'post',
function(response) {
if (!response || response.error) {
//Debug
alert('Error occured ' + response.error);
} else {
// Debug
alert('Listen was successful! Action ID: ' + response.id);
}
});
//jwplayer().load(songs_position_url[position]);
}
Note, this works because I have setup the facebook OpenGraph tags on each album/song pages that are required to use the content in the context of facebook/opengraph objects.
Now that I know that this process works, I wish to develop this further so that it works for plays on songs, song, playlists and album views & the module where;
[ol]
[li]In album/playlists and songs, I want the event to trigger not just on the play button, but also, when the next song(s) are played automatically. E.g. If I click play on an album page and listen to the whole album, I want to trigger the same event after each song has finished.[/li]
[li]In song pages (single player), clicking the player's play button triggers the same facebook event.[/li]
[/ol]
In each case, I only want the event to trigger when an entire song has been played or maybe, when it has reached the middle of the song, I will trigger a dialog box asking if the user wishes to share this song.
Given that muscol/jwplayer already have listeners/events that are being used to track plays, I should be able to add the same type of edit above to the the JS files, right?
Could you please advise me which files/functions I will need to edit in order to make this work?
Naturally, I'd be completely happy to share the entire working code if you wish, including the custom integration that I've written for JFBConnect that dynamically writes facebook's OpenGraph tags for album/artist/song pages.
Many thanks in advance!
Gez
Responses (6)
-
Accepted Answer
0Hi Germi,
Have you had a chance to take a look at this yet?
Just to clarify, I'm only really looking for help locating the file(s)/functions that I need to edit to make this work. I can handle the facebook side of things ok. I just need to bind the facebook stuff to the existing functions (hopefully).
One other question, At what point during playback of a song does the play count for it get incremented and inside which file/function?
many thanks,
Gez -
Accepted Answer
0hello!
great work you are doing on all that. I've seen your other forum potsts, too. it seems like you have your Code Jedi on!
the JS function you're looking for is:
function add_song_play_count(song_id)
in the same file, playlist functions. this is triggered everytime a new song is played (autoamtically or manually), but always AT THE BEGINNING.
if you want to change this behavior to be at the middle or end.. well this changes everything. in this case you should go to the JWPLAYER API (look on their site) and add a listener to the player that tells you when the song ends or whatever. but again, this makes the work much complicated. -
Accepted Answer
0Hi Germi,
Thanks for this!
I'm gonna update and test the add_song_play_count(song_id) function with my code...
Sure, I understand that changing point at which the event triggers adds complexity. In the meantime (or possibly instead), I'll try deferring the event for 30 seconds and maybe add a confirmation dialog.
I'll let you know the outcome.
Also, I'm gonna reply to the comments post i a mo too!
many thanks,
Gez -
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 »