Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
bbakernc
Visitor

Key Press call URL

I am looking for a way to track when someone actually clicks on the Play or Resume button.

I would be great if I could do something simple like

if PlayStart <> invalid then
http://mysite.com/track.php?id=156
showList[showIndex].PlayStart = PlayStart.ToInt()
endif
0 Kudos
11 REPLIES 11
TheEndless
Channel Surfer

Re: Key Press call URL

Why can't you? Just add a GetToStringAsync call to your Play/Pause/Resume handling, whether that's via your event loop or your custom Play/Pause routine...
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
dynamitemedia
Binge Watcher

Re: Key Press call URL

if PlayStart <> invalid then              
m.UrlTrack ="http://yoursite.com/track.php"
http = NewHttp(m.UrlTrack)

id = showList[showIndex].ContentId
http.AddParam("id", id)

rsp = http.Http.GetToString()
print "ID passed to track.php is: "; id

showList[showIndex].PlayStart = PlayStart.ToInt()
showVideoScreen(showList[showIndex])
refreshShowDetail(screen, showList, showIndex)
endif

this is similar to how we do it, you can add to google analytics etc in the php... Maybe endless can explain more on what he is showing and possible code so you can better make a decision on which method you would like to use, i have never used his method... hope this helps a little, i know for me it helps to see some code
Twitter: iptvmyway facebook: iptvmyay
Channels: Warriors of War, Go Fight Live, Heading Outdoorz, IPTVmyway
0 Kudos
bbakernc
Visitor

Re: Key Press call URL

THANKS, this looks like what we are needing. All of our Normal web streams report to Google. We were going to just add a Curl and report from the server.... but this looks promising.

THANKS
0 Kudos
dynamitemedia
Binge Watcher

Re: Key Press call URL

in your php you can grab the "id" using:

$videoID = $_REQUEST["id"];

and then do anything you need from here with $videoID
Twitter: iptvmyway facebook: iptvmyay
Channels: Warriors of War, Go Fight Live, Heading Outdoorz, IPTVmyway
0 Kudos
TheEndless
Channel Surfer

Re: Key Press call URL

Unless you need the contents of the web request, I would recommend using AsyncGetToString instead of GetToString, otherwise you'll block until the request returns, which may not be desirable.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
dynamitemedia
Binge Watcher

Re: Key Press call URL

otherwise you'll block until the request returns, which may not be desirable


could you please explain more? cause i have not seen any sort of slowdown or anything using this method, in fact it i was under the impression this would be happening while the video was playing. as soon as the button is pushed the video is playing and the info is at the website instantly, in fact miliseconds, so would love to know how this could be a problem?

an explanation with some code would be very helpful for myself and any future developers to learn from when searching the forum.
Twitter: iptvmyway facebook: iptvmyay
Channels: Warriors of War, Go Fight Live, Heading Outdoorz, IPTVmyway
0 Kudos
kbenson
Visitor

Re: Key Press call URL

"dynamitemedia" wrote:
otherwise you'll block until the request returns, which may not be desirable


could you please explain more? cause i have not seen any sort of slowdown or anything using this method, in fact it i was under the impression this would be happening while the video was playing. as soon as the button is pushed the video is playing and the info is at the website instantly, in fact miliseconds, so would love to know how this could be a problem?

an explanation with some code would be very helpful for myself and any future developers to learn from when searching the forum.


While the network and your server are all responding fine, it should return quickly. If for some reason that URL stalls for a little bit, or the connection is laggy, subsequent commands won't run until the page either finishes responding or times out (unless you are doing the async call). During normal conditions, that's not generally a problem. During problematic conditions, it could have interesting side-effects, depending on your program's control flow.

If you don't actually need to know what your server responded with, do the async call and ignore the response. It will generate a msg on completion, and you can ignore or handle that as you see fit.
-- GandK Labs
Check out Reversi! in the channel store!
0 Kudos
TheEndless
Channel Surfer

Re: Key Press call URL

"dynamitemedia" wrote:
in fact it i was under the impression this would be happening while the video was playing.

Not in the code you posted, it isn't. Your code is doing the synchronous GetToString before the video has started (showVideoScreen()). With a fast connection, and a quick server response, you probably won't notice, but as kbenson explained, if there's any delay in the request (due to high server load, temporary network glitch, etc), then you will see a delay between the button press and video playback. An asynchronous request would not suffer from such a delay, because it doesn't wait for the web site to respond before continuing execution.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
dynamitemedia
Binge Watcher

Re: Key Press call URL

I made that code quick cause i have mine used in a sub, so i just did it quick, so go ahead and change it around and play first, cause thats how i have it in mine in fact looks like this:
             showList[showIndex].PlayDuration = 0
videosWatched()
showVideoScreen(showList[showIndex])
refreshShowDetail(screen, showList, showIndex)

but i just tested it the other way and it was the same milisecond to play.... so bbakernc i guess you will need to decide what you want to do, i sometimes want info sent back to me sometimes no, so i just kept this style code throughout as its easy to duplicated if needed elsewhere.

i have never used their method so i can only help with what works with mine. I can tell you in over 6 months of development i have yet to see any issue or latency, doesn't mean its not possible. and it sounds like they are correct,after reading the docs, But i don't see any code there to help you out so maybe try to search the forum or maybe someone could show you some code to work with.

Good Luck
Twitter: iptvmyway facebook: iptvmyay
Channels: Warriors of War, Go Fight Live, Heading Outdoorz, IPTVmyway
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.