|
SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here. |
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
Starting playback in Sage from java?
I'm trying to get my java plugin to start playback of a media file. The only applicable API call I've found is Watch() in the MediaPlayer API. I pass it in a media file, and it returns an object that is either "true" if it worked, or a "localized error message".
Well, it doesn't work, and the message it returns (when I output it via .toString()) is something unhelpful like sage.e$a@23244. Is there a better way, via java, to start playback, or is there at least some way I can learn what this error message is? |
#2
|
||||
|
||||
Check the log file; it should have more error data there.
__________________
Jeffrey Kardatzke Founder of SageTV |
#3
|
|||
|
|||
Doh! That's a good idea. I had the console window open and didn't see a message there, but forgot to check the debug log. I'll see what it says tonight.
|
#4
|
||||
|
||||
also print out your media file object , just to check that it is correct (the object you pass to Watch())
Note that if you are using GKusnik's wrappers, you need to unwrap his MediaFileAPI.MediaFile object to get the Sage MediaFile object to pass to Watch() using MediaFileAPI.unwrap()
__________________
Check out my enhancements for Sage in the Sage Customisations and Sageplugins Wiki Last edited by nielm; 04-16-2007 at 11:45 AM. |
#5
|
||||
|
||||
Good point; I should have picked up on that sooner. Because the Content argument is declared as Object, the wrapper generator doesn't realize it needs to be unwrapped.
In the next release I'll add type-specific overloads for wrapped Airings and MediaFiles to do the unwrapping automatically. Meanwhile, do what Niel said and use MediaFileAPI.Unwrap to get the underlying MediaFile object to pass to Watch.
__________________
-- Greg |
#6
|
|||
|
|||
Great! It works!
When I start it playing a show from the sage menu screen, I can hear it playing, but it still shows the sage menu. I think this is similar to when you have a channel selected and it's playing kind of behind the menu, because when i go to "Watch Live TV", I see the video playing in the upper right corner. So I'll have to dig into the API and find a way that will send it to the video even if on the sage main menu. Thanks so much for all your help. |
#7
|
||||
|
||||
If by "send it to the video" you mean switch to the Media Player OSD screen, then you need to tell Sage to load that menu using LaunchMenuWidget.
__________________
-- Greg |
#8
|
|||
|
|||
Sadly, I don't even know enough to form the right kind of questions....
I start off at the blue Sage main menu (when Sage first loads), and I click my button to start the media file playing, and I can hear it in the background, but it's still showing the menu. I forget what menu I have to select to finally see the video itself. So I need to learn widgets, eh? I started looking through the widget api, and saw lots of references to creating widgets of different types...so I'll be shooting for the media player OSD then. Hopefully there's a good reference for those somewhere in the forums. Thanks for the help, again! |
#9
|
||||
|
||||
You don't need to create any widgets (unless you're actually trying to modify the STV). You just need to find the existing Menu widget whose name is "MediaPlayer OSD" and launch it. Roughly:
Code:
api.FindWidget("Menu", "MediaPlayer OSD").LaunchMenuWidget(); Basically, the Watch() API instructs the server to start streaming the media content, and the client to start receiving and decoding it. But that by itself doesn't change the state of the UI, which is completely controlled by the STV. So you also have to tell the STV to display its media playback screen in order to see what's being played back.
__________________
-- Greg |
#10
|
||||
|
||||
My webserver does:
SageCommand("Home") SageCommand("TV") when initiating playback to go to the TV screen. That way it should be STV-independant. (HOME is sent first, because if you are already on the TV display, the "TV" command sends you back to the last menu)
__________________
Check out my enhancements for Sage in the Sage Customisations and Sageplugins Wiki Last edited by nielm; 04-17-2007 at 03:09 AM. |
#11
|
||||
|
||||
Yeah, that's a better way to do it. It's still up to the STV to do the right thing with the "Home" and "TV" commands, but using the command names should be safer than hard-coding the menu name.
__________________
-- Greg |
#12
|
|||
|
|||
Brilliant! I'll have to put that in tonight.
This stuff is making the home automation guys very happy. |
#13
|
||||
|
||||
btw , I saw in one of your other posts that you were sending arrays of MediaFile data from Sage to your app, and then sending back an array index to select one... For most objects, you can request it's unique integer ID (GetMediaFileID()/GetMediaFileForID()), and that would be more reliable than the index of an array that may have changed between request/response...
__________________
Check out my enhancements for Sage in the Sage Customisations and Sageplugins Wiki |
#14
|
|||
|
|||
Ya,that's a good idea. The index was a quicky "let's see if it works" kinda thing, and I'm pleased to see it does. But it needs a lot more armour plating on it! A media file ID is definitely the way to go, because I"m sure it won't take long for the arrays to get out of synch.
I noticed when I did a GetAllMediaFiles() call that the array that was returned had nothing in the first array location. In other words, I did a GetTitle() on all those media files, and the first array location returned a null string. Is that something I can rely on, and so I should basically index the array from 1 instead of 0? |
#15
|
||||
|
||||
You will need to filter the media files to get the ones that you are interested in (TV files, Library files)....
eg, for TV files (both archived and not) Code:
files=GetMediaFiles() // get TV files files = FilterByBoolMethod(files, "IsTVFile", true) // ignore partials. files=FilterByBoolMethod(files, "IsCompleteRecording|IsManualRecord", true)
__________________
Check out my enhancements for Sage in the Sage Customisations and Sageplugins Wiki |
#16
|
|||
|
|||
Oooooo, I understand the FilterByBoolMethod's now. Basically, you take a list of items, like media files, and you filter them by the name of a media file method that you could normally call to get a true/false result.
So, mediafile.IsTVFile()....that's a mediafile method. so, you'd pass in the NAME of the function you'd execute on the media file. I couldn't figure those out. That helps a lot. I have to figure out the Sort's next, because I want to sort by "most recently recorded first". |
#17
|
||||
|
||||
The best way to figure out how to use the various APIs is to study working code that uses them. By far the biggest collection of such code is in the stock STV, so it's probably worth your while at some point to open up Studio and start familiarizing yourself with how an STV works. Even if you don't plan on writing any STV code, a lot of what you're trying to do is similar to what an STV does, so it makes sense to take advantage of that learning resource.
__________________
-- Greg |
#18
|
|||
|
|||
Ya, I've got a nice copy of nielm's code handy, and I've been harvesting info from them when I can. The Filter by bool thing, though, I just coudn't make the mental leap on what it was actually doing until I saw it in his post.
|
#19
|
||||
|
||||
The webserver code is a bit of a pain to follow sometimes beccause some of the customisable sort/filter methods are stored in cookies...
Also 2, I didn't really know what I was doing in places, so I ducplicated the STV's code flow in Java. Also 3 I didn't realise when I wrote certain screens that the 'EvaluateExpression'() method was available, so in the webserver, you see a lot of sequential calls with static parameters like: Code:
Object filelist=SageApi.Api("GetMediaFiles"); Object RecordedFiles=SageApi.Api("FilterByBoolMethod",new Object[]{filelist, "IsTVFile", Boolean.TRUE}); RecordedFiles=SageApi.Api("FilterByBoolMethod",new Object[]{filelist, "IsCompleteRecording|IsManualRecord", Boolean.TRUE}); Code:
Object RecordedFiles=SageApi.Api("EvaluateExpression",new Object[]{ "FilterByBoolMethod(FilterByBoolMethod(GetMediaFiles(),\"IsTVFile\",true),\"IsCompleteRecording|IsManualRecord\",true)" });
__________________
Check out my enhancements for Sage in the Sage Customisations and Sageplugins Wiki |
#20
|
|||
|
|||
Stack trace?? You're able to step through your java code while it's talking to Sage? What are you using, netbeans? I thought the code had to be executed from within sage to work, so I didn't figure there was a debugger for it.
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Sage Client slowing HD playback | simonen | SageTV Software | 2 | 02-01-2007 08:24 PM |
Lost recording directory after starting Sage server | judy2304 | SageTV Software | 1 | 01-30-2007 10:16 AM |
Sage UI disappears during playback | Keith | SageTV Software | 17 | 03-03-2006 03:31 AM |
How To: In-place recompression of Sage Recordings | nielm | SageTV Customizations | 39 | 02-18-2006 11:32 PM |
Sage crashes | rfutscher | SageTV Software | 0 | 01-23-2006 04:31 PM |