Page 1 of 1
Notify of Played Item

Posted:
Wed Jan 04, 2012 4:59 pm
by nutt318
I was wondering if its possible to have Subsonic send an email when a movie/tv show is being played. Just would like to know when someone is using subsonic and my bandwidth. I know I can view this within the subsonic who is playing what but I'd rather it send me an email.
Anyways if anyone has any ideas I would appreciate it.
Thanks!
Re: Notify of Played Item

Posted:
Tue Jan 10, 2012 10:40 am
by ytechie
I know how to get subsonic to trigger anything when a song is played, but I don't know off-hand how to send an email.
Your best bet is a php script. If you get a php script set up to send an email, we can get it working with subsonic in no time!

Re: Notify of Played Item

Posted:
Tue Jan 10, 2012 3:23 pm
by nutt318
Oh, well I've got a php script I've used in the past. Let me find it and I'll post the code here if you need it.
Re: Notify of Played Item

Posted:
Tue Jan 10, 2012 9:52 pm
by ytechie
Is it hosted? I don't know how jetty handles php.

I know this may sound crazy, but if you can find a way to send an email by adding parameters to the url, (like a GET request), I could trigger it very very easily.
Re: Notify of Played Item

Posted:
Tue Jan 10, 2012 10:55 pm
by nutt318
I have it installed on my server at home. So I could use my ISP's smtp relay for sending messages as well.
Re: Notify of Played Item

Posted:
Tue Jan 10, 2012 10:56 pm
by ytechie
How do you make the script work? Let's get this started!
Re: Notify of Played Item

Posted:
Thu Jan 12, 2012 10:08 pm
by nutt318
So how do you get it to trigger a .php file if a movie/tv show is played?
I've got 2 .php files that should do the trick.
Re: Notify of Played Item

Posted:
Fri Jan 13, 2012 12:38 am
by ytechie
Well, you have to put the the trigger in the playAddDownload.jsp file if you only want it to trigger on movies/TV shows. Here is the part of that file that we will be editing:
- Code: Select all
<c:choose>
<c:when test="${param.video}">
<sub:url value="/videoPlayer.view" var="videoUrl">
<sub:param name="path" value="${param.path}"/>
</sub:url>
<a href="${videoUrl}" target="main">
<img src="<spring:theme code="playImage"/>" alt="<fmt:message key="common.play"/>" title="<fmt:message key="common.play"/>"></a>
</c:when>
<c:otherwise>
<a href="javascript:noop()" onclick="top.playlist.onPlay('${path}');">
<img src="<spring:theme code="playImage"/>" alt="<fmt:message key="common.play"/>" title="<fmt:message key="common.play"/>"></a>
</c:otherwise>
</c:choose>
More specifically,
- Code: Select all
<a href="${videoUrl}" target="main">
Just write a javascript script at the top of the page, and insert the ol' "onclick='yourFunction()'.
That's all there is to it.
I actually have it running a script when a video is played. However, I have the script in the playlist.jsp file, so I just reference it using "onclick='top.playlist.myFunction()'".
Hope this helps!
Re: Notify of Played Item

Posted:
Mon Apr 30, 2012 6:45 pm
by nutt318
Ok, so back to this post again.
I'm not sure if I should use java script to send the email or have JavaScript call a .php file to send the email.
Also I'm not sure what file to actually edit and want to try and get this figured out.
Thanks!
Re: Notify of Played Item

Posted:
Mon Apr 30, 2012 8:50 pm
by nutt318
So I've got this and it sorta works except for it pops open my default mail client, anyone know of a way to have it send the email behind the scenes?
Also maybe include the video being watched along with the username of whos playing the content.
The code thats at the top of playAddDownload.jsp
- Code: Select all
<script>
function sendMail() {
var link = "mailto:me@example.com"
+ "&subject=" + escape("This is my subject")
+ "&body=" + escape("myText")
;
window.location.href = link;
}
</script>
The code that is executed on the clicking of play
- Code: Select all
<a href="${videoUrl}" target="main" onclick="sendMail()">
Re: Notify of Played Item

Posted:
Tue May 01, 2012 1:33 am
by ytechie
Sending email behind the scenes was always sort of a mystery for me. In some languages it is easy to do (PHP), but in others, very hard.
Re: Notify of Played Item

Posted:
Tue May 01, 2012 3:32 pm
by nutt318
I've got a .php page loaded on my site that when you access it, it will send an email.
Do you know of a way to have a javascript function call or execute a webpage without it actually being displayed? If so then I think I can get it working. However I'm sure there is a better way to accomplish this. Or if I could put PHP code within the .jsp file, which I dont think is possible.
Re: Notify of Played Item

Posted:
Wed May 02, 2012 7:40 pm
by nutt318
Got it figured out thanks to some help of a co-worker of mine. Anyways I posted the how to in the tutorial section
viewtopic.php?f=6&t=9443