SageTV Community  

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

Notices

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.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-16-2007, 08:00 AM
beelzerob beelzerob is offline
Sage Advanced User
 
Join Date: May 2006
Posts: 163
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?
Reply With Quote
  #2  
Old 04-16-2007, 09:59 AM
Narflex's Avatar
Narflex Narflex is offline
Sage
 
Join Date: Feb 2003
Location: Redondo Beach, CA
Posts: 6,349
Check the log file; it should have more error data there.
__________________
Jeffrey Kardatzke
Google
Founder of SageTV
Reply With Quote
  #3  
Old 04-16-2007, 10:14 AM
beelzerob beelzerob is offline
Sage Advanced User
 
Join Date: May 2006
Posts: 163
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.
Reply With Quote
  #4  
Old 04-16-2007, 11:00 AM
nielm's Avatar
nielm nielm is offline
SageTVaholic
 
Join Date: Oct 2003
Location: Belgium
Posts: 4,496
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.
Reply With Quote
  #5  
Old 04-16-2007, 12:09 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
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
Reply With Quote
  #6  
Old 04-16-2007, 08:33 PM
beelzerob beelzerob is offline
Sage Advanced User
 
Join Date: May 2006
Posts: 163
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.
Reply With Quote
  #7  
Old 04-16-2007, 09:19 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
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
Reply With Quote
  #8  
Old 04-16-2007, 09:49 PM
beelzerob beelzerob is offline
Sage Advanced User
 
Join Date: May 2006
Posts: 163
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!
Reply With Quote
  #9  
Old 04-17-2007, 12:28 AM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
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();
That's assuming of course that you're using the stock STV, or some other STV that contains a menu by that name.

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
Reply With Quote
  #10  
Old 04-17-2007, 12:55 AM
nielm's Avatar
nielm nielm is offline
SageTVaholic
 
Join Date: Oct 2003
Location: Belgium
Posts: 4,496
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.
Reply With Quote
  #11  
Old 04-17-2007, 01:21 AM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
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
Reply With Quote
  #12  
Old 04-18-2007, 07:11 AM
beelzerob beelzerob is offline
Sage Advanced User
 
Join Date: May 2006
Posts: 163
Brilliant! I'll have to put that in tonight.

This stuff is making the home automation guys very happy.

Reply With Quote
  #13  
Old 04-18-2007, 09:42 AM
nielm's Avatar
nielm nielm is offline
SageTVaholic
 
Join Date: Oct 2003
Location: Belgium
Posts: 4,496
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
Reply With Quote
  #14  
Old 04-18-2007, 10:07 AM
beelzerob beelzerob is offline
Sage Advanced User
 
Join Date: May 2006
Posts: 163
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?
Reply With Quote
  #15  
Old 04-18-2007, 10:51 AM
nielm's Avatar
nielm nielm is offline
SageTVaholic
 
Join Date: Oct 2003
Location: Belgium
Posts: 4,496
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)
There are some mediafiles that are created and used internally (1 per tuner input) - the one at index 0 might have been one of these..
__________________
Check out my enhancements for Sage in the Sage Customisations and Sageplugins Wiki
Reply With Quote
  #16  
Old 04-18-2007, 11:02 AM
beelzerob beelzerob is offline
Sage Advanced User
 
Join Date: May 2006
Posts: 163
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".
Reply With Quote
  #17  
Old 04-18-2007, 11:40 AM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
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
Reply With Quote
  #18  
Old 04-18-2007, 11:55 AM
beelzerob beelzerob is offline
Sage Advanced User
 
Join Date: May 2006
Posts: 163
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.
Reply With Quote
  #19  
Old 04-19-2007, 01:24 AM
nielm's Avatar
nielm nielm is offline
SageTVaholic
 
Join Date: Oct 2003
Location: Belgium
Posts: 4,496
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});
whereas it would have been perhaps a lot clearer if I used EvaluateExpression to pass in a string, so it would look more like the code you see in the STV:
Code:
Object RecordedFiles=SageApi.Api("EvaluateExpression",new Object[]{
    "FilterByBoolMethod(FilterByBoolMethod(GetMediaFiles(),\"IsTVFile\",true),\"IsCompleteRecording|IsManualRecord\",true)"
});
On the other hand calling the functions individually allows for easy bug tracing: in the stack trace you see exactly which function call triggered the exception.
__________________
Check out my enhancements for Sage in the Sage Customisations and Sageplugins Wiki
Reply With Quote
  #20  
Old 04-19-2007, 06:55 AM
beelzerob beelzerob is offline
Sage Advanced User
 
Join Date: May 2006
Posts: 163
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.
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
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


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


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