SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Github Development
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Github Development Discussion related to SageTV Open Source Development. Use this forum for development topics about the Open Source versions of SageTV, hosted on Github.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-21-2016, 09:51 PM
jonnydeath jonnydeath is offline
Sage User
 
Join Date: Apr 2008
Posts: 52
UIContext Help

I am playing around with sagex api (javascript version you put in the sagex directory), but I cannot figure out how to pass a UIContext to the Watch command. Any ideas? I have found examples for java and for the URL api, but cant figure out how to declare a new context in the javascript.

I am using Sage Opensource, but it says my Sagex is at 7.1.9.1. Is this normal?

My eventual (lofty) goal is to make an alexa skill that will search for a show and play it on a extender.

I can already use sagex to:
Search for airing
Get Media file from the airing
return Show/Episode Title in json

Once I can watch, I will tackle the alexa part yet, but should be straightforward if a single URL call.

Last edited by jonnydeath; 04-22-2016 at 04:31 AM.
Reply With Quote
  #2  
Old 04-22-2016, 07:48 AM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
In most cases the UIContext parameter is not needed. Just use the form of the API that does not require the UIContext parameter.
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #3  
Old 04-22-2016, 10:27 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Quote:
Originally Posted by jonnydeath View Post
I am playing around with sagex api (javascript version you put in the sagex directory), but I cannot figure out how to pass a UIContext to the Watch command. Any ideas? I have found examples for java and for the URL api, but cant figure out how to declare a new context in the javascript.
In your script you can use GetConnectedClients api to get the currently connected clients. And then in the Watch api, pass the client id. If you are using sagex apis (instead of the call() command), then create a new UIContext("contextid") and pass that as the first parameter of the Watch api method.

Quote:
Originally Posted by jonnydeath View Post
I am using Sage Opensource, but it says my Sagex is at 7.1.9.1. Is this normal?
sagex is independent of SageTV (it's an add-on). 7.1.9.x means that the API for sagex is at 7.1.9, and I haven't created a 9.0.x sagex, yet.
Reply With Quote
  #4  
Old 04-22-2016, 09:28 PM
jonnydeath jonnydeath is offline
Sage User
 
Join Date: Apr 2008
Posts: 52
I am honored you replied, but I just can't get it. In the javascript called by:
http://iport/sagex/api?c=file:Function

MediaPlayerAPI.Watch(mf); % This does not error, but does not play
----------
var names = Global.GetConnectedClients();
MediaPlayerAPI.Watch(names[0],mf); % Gives: Can't find method sagex.api.MediaPlayerAPI.Watch(java.lang.String,sage.MediaFile)

------

MediaPlayerAPI.Watch(UIContext(names[0]),mf); % Gives:"UIContext" is not defined.
Reply With Quote
  #5  
Old 04-23-2016, 04:19 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Quote:
Originally Posted by stuckless View Post
In your script you can use GetConnectedClients ... then create a new UIContext("contextid") ...
Quote:
Originally Posted by jonnydeath View Post
I am honored you replied, but I just can't get it. In the javascript called by:
http://iport/sagex/api?c=file:Function

MediaPlayerAPI.Watch(mf); % This does not error, but does not play
----------
var names = Global.GetConnectedClients();
MediaPlayerAPI.Watch(names[0],mf); % Gives: Can't find method sagex.api.MediaPlayerAPI.Watch(java.lang.String,sage.MediaFile)

------

MediaPlayerAPI.Watch(UIContext(names[0]),mf); % Gives:"UIContext" is not defined.
I wasn't really clear, but, in my previous comment the new UIContext("contextid") part was somewhat literal. ie, the first parameter to Watch() would be a UIContext object and not a String.

so you might need to do this...

Code:
var UIContext =  Packages.sagex.UIContext;
var names = Global.GetConnectedClients();
MediaPlayerAPI.Watch(new UIContext(names[0]),mf);
Reply With Quote
  #6  
Old 04-23-2016, 08:19 AM
jonnydeath jonnydeath is offline
Sage User
 
Join Date: Apr 2008
Posts: 52
Thank you. Works.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Detecting UIContext Type? broconne SageTV Studio 12 04-06-2011 07:10 AM
Getting a valid UIContext from 3rd party apis razrsharpe SageTV Studio 3 12-16-2009 10:05 PM
6.4.8 Broken "new API(uiContext)"? Fonceur SageTV Beta Test Software 10 08-18-2008 10:41 PM


All times are GMT -6. The time now is 05:50 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.