# callback question with RTMPVideoItem

**URL:** <https://forums.plex.tv/t/callback-question-with-rtmpvideoitem/3967>\
**Category:** Dev/API Corner\
**Tags:** plugin-dev\
**Created:** [April 27, 2010, 4:36pm UTC](https://forums.plex.tv/t/callback-question-with-rtmpvideoitem/3967 "2010-04-27T16:36:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdevoo](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/jdevoo/32/123481_2.png) [@jdevoo](https://forums.plex.tv/u/jdevoo)\
**Post date:** [April 27, 2010, 4:36pm UTC](https://forums.plex.tv/t/callback-question-with-rtmpvideoitem/3967/1 "2010-04-27T16:36:40Z")

</div>

Hello folks,  
  
  
  
I am having to resolve RTMP URLs which require an additional request. As this is time-consuming, I created a callback function and pass it to RTMPVideoItem like this:  
  
  
  
dir.Append(Function(RTMPVideoItem(PlayForaVideo, title=title, subtitle=subtitle, summary=summary, thumb=FTV\_ROOT+thumb), url=FTV\_ROOT+key))  
  
  
  
Then the callback function:  
  
def PlayForaVideo(sender, url):  
  
page = HTTP.Request(url)  
  
clipid = re.search(‘var full\_program\_clipid = (.+?);’, page, re.DOTALL).group(1)  
  
doc = XML.ElementFromURL(FTV\_ROOT+FORA\_PLAYER % clipid, False)  
  
clip = re.search(’^(.\*)(.flv)$’, doc.xpath(’/playerdata/encodeinfo/encode\_url’)[0].text).group(0)  
  
Redirect(LLNW\_ROOT+’/’+clip)  
  
  
  
My question:  
  
RTMPVideoItem really requires two parameters and I’m returning only one from the callback. How can I do this and does it even work with Redirect? I only read about a same-protocol restriction so I figured it should work…  
  
  
  
TIA  
  
  
  
JP

---

<div class="post-metadata">

**Author:** ![sander1](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@sander1](https://forums.plex.tv/u/sander1)\
**Post date:** [April 27, 2010, 4:52pm UTC](https://forums.plex.tv/t/callback-question-with-rtmpvideoitem/3967/2 "2010-04-27T16:52:56Z")

</div>

Hello Jean-Paul!  
  
  
  
When you’re using a WebVideoItem or RTMPVideoItem in combination with a Redirect, you have use a WebVideoItem or RTMPVideoItem in the return value. I think an example explains it much better:  
  
  
  
Use WebVideoItem when building your list with videos, like so:

```auto

dir.Append(Function(WebVideoItem(PlayForaVideo, title=title, subtitle=subtitle, summary=summary, thumb=FTV_ROOT+thumb), url=FTV_ROOT+key))

```

  
  
Then you can return an RTMPVideoItem (or WebVideoItem) to it:  

```auto

def PlayForaVideo(sender, url):<br />
  ...<br />
  ...<br />
  return Redirect(RTMPVideoItem( LLNW_ROOT, clip ))

```

---

<div class="post-metadata">

**Author:** ![jdevoo](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/jdevoo/32/123481_2.png) [@jdevoo](https://forums.plex.tv/u/jdevoo)\
**Post date:** [April 27, 2010, 7:48pm UTC](https://forums.plex.tv/t/callback-question-with-rtmpvideoitem/3967/3 "2010-04-27T19:48:01Z")

</div>

Hi Sander and thanks for the prompt reply.  
  
  
  
I changed the code and tested my data using the site player  
  
  
  
Site player works fine with url and clip as in [here](http://www.plexapp.com/player/player.php?url=rtmp://foratv.fcod.llnwd.net/a953/o10&clip=2010-04-10_goodman_FORAcast-16x9-HDV-384kbps-10611)  
  
  
  
But my code which has been changed accordingly still returns “Request not handled by plug-in.”  
  
  
  
Will keep looking…

---

<div class="post-metadata">

**Author:** ![sander1](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@sander1](https://forums.plex.tv/u/sander1)\
**Post date:** [April 27, 2010, 9:00pm UTC](https://forums.plex.tv/t/callback-question-with-rtmpvideoitem/3967/4 "2010-04-27T21:00:15Z")

</div>

Hi Jean-Paul,  
  
I’m not sure what’s going wrong, maybe you can try to Log() some stuff and see if any of the variables is incorrect. You can also build the correct url (http:// [www.plexapp.com/player/player.php...etc.)](http://www.plexapp.com/player/player.php...etc.)) yourself and just use a WebVideoItem in your PlayForaVideo function too:

```auto

def PlayForaVideo(sender, url):<br />
  ...<br />
  ...<br />
  url = 'http://www.plexapp.com/player/player.php?url=rtmp://foratv.fcod.llnwd.net/a953/o10&clip=2010-04-10_goodman_FORAcast-16x9-HDV-384kbps-10611'<br />
  return Redirect(WebVideoItem(url))<br />

```

---

<div class="post-metadata">

**Author:** ![jdevoo](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/jdevoo/32/123481_2.png) [@jdevoo](https://forums.plex.tv/u/jdevoo)\
**Post date:** [April 30, 2010, 3:48pm UTC](https://forums.plex.tv/t/callback-question-with-rtmpvideoitem/3967/5 "2010-04-30T15:48:44Z")

</div>

Thank you Sander!  
  
I finally noticed my mistake. Forgot the return in front of Redirect. My function ended with Redirect and not return Redirect.  
  
Getting near completion of this plug-in.  
  
JP

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [December 20, 2019, 8:38pm UTC](https://forums.plex.tv/t/callback-question-with-rtmpvideoitem/3967/6 "2019-12-20T20:38:37Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
