TV4Home - WCF Webservice for MediaPortal TV Server (1 Viewer)

mpolan

Portal Member
January 22, 2011
10
0
Hi Mike! I've also posted on your other thread re: IMediaAccesService - same issue here, the references in your WSDL and XSD are to localhost, a relative path would be easier when using the WSDL to generate web service clients. Turns out the services here are the ones I need.

I did manage to get things working (at last as far as testConnectionToServer() returns true). One minor issue I found in the install was that while you create a firewall rule for the TVEInteration service, you dont' create a port exception.

Thanks for this great plugin!

Progress update (sorry for the double post), I've got a few services working well now - getGroups, getSchedules, testConnection, so the basic interaction seems to be working.

I'm having trouble with a few calls - getChannels, getChannelsById, getProgramForChannel, I get an exception that possibly suggests something is missing from the WSDL (or quite likely I messed it up when modifying it to generate my client).

UPDATE on my calling troubles - it's is likely because I used an older WSDL that was posted earlier in this thread. I noticed the links to retrieve the newer WSDL and the service definitions there have changed, I'll retry with the new definitions.
 

mpolan

Portal Member
January 22, 2011
10
0
Hi again Mike:

I seem to be moving along well using this service. I'm having a little trouble with canceling scheduled recordings (when the schedule is not "once'. I think there might be a bug here in the ITVEInteraction service below. The line
Code:
    new CanceledSchedule(schedule.IdSchedule, schedule.IdChannel, schedule.StartTime);
I think should be:
Code:
    new CanceledSchedule(schedule.IdSchedule, program.IdChannel, program.StartTime);
Do I have it right? (I'm probably not putting this in the right place, let me know if I should post elsewhere).

Code:
        public void CancelSchedule(int programId)
        {
            Program program = Program.Retrieve(programId);

            foreach (Schedule schedule in Schedule.ListAll().Where(schedule => schedule.IsRecordingProgram(program, true)))
            {
                switch (schedule.ScheduleType)
                {
                    case (int)ScheduleRecordingType.Once:
                        schedule.Delete();
                        _tvControl.OnNewSchedule();
                        break;
                    default:
                        CanceledSchedule canceledSchedule = new CanceledSchedule(schedule.IdSchedule, schedule.IdChannel, schedule.StartTime);
                        canceledSchedule.Persist();
                        _tvControl.OnNewSchedule();
                        break;
                }
            }
        }
 

mpolan

Portal Member
January 22, 2011
10
0
Another problem, this time for "deleteSchedule" - it seems to be leaving entries in the canceledschedule table for that schedule - I'm guessing they need to be cleaned out by the extension as well.
 

mpolan

Portal Member
January 22, 2011
10
0
Hi Mike - I had some fun today figuring out Microsoft's visual workbench, C#, and even got your plugin to build and installed on my system. So I was able to verify that the fix above for canceling a single episode does work.

I struggled a bit getting deleteSchedule to work properly, the current version seems to leave around the scheduled programs still marked to be recorded in the db.

Here's what I got working - I expect there's an easier/faster way, but this works for now:

Code:
        public void DeleteSchedule(int scheduleId)
        {
            Schedule schedule = Schedule.Retrieve(scheduleId);
            // mgp first cancel all of the episodes of this program for this schedule
            foreach (Program program in Program.ListAll().Where(program => program.Title == schedule.ProgramName))
            {
                if (schedule.IsRecordingProgram(program, true))
                {
                    CanceledSchedule canceledSchedule = new CanceledSchedule(schedule.IdSchedule, program.IdChannel, program.StartTime);
                    canceledSchedule.Persist();
                    _tvControl.OnNewSchedule();
                }
            }
            // now remove existing CanceledSchedule for this schedule
            foreach (CanceledSchedule canceled in CanceledSchedule.ListAll().Where(canceled => canceled.IdSchedule == schedule.IdSchedule))
            {
                canceled.Remove();
            }
            schedule.Remove();
            _tvControl.OnNewSchedule();
        }

and my version of CancelSchedule:

Code:
public void CancelSchedule(int programId)
        {
            Program program = Program.Retrieve(programId);

            foreach (Schedule schedule in Schedule.ListAll().Where(schedule => schedule.IsRecordingProgram(program, true)))
            {
                switch (schedule.ScheduleType)
                {
                    case (int)ScheduleRecordingType.Once:
                        schedule.Delete();
                        _tvControl.OnNewSchedule();
                        break;
                    default:
                        // mgp fixed schedule.IdChannel, schedule.StartTime - was canceling only the first scheduled show...
                        CanceledSchedule canceledSchedule = new CanceledSchedule(schedule.IdSchedule, program.IdChannel, program.StartTime);
                        canceledSchedule.Persist();
                        _tvControl.OnNewSchedule();
                        break;
                }
            }
        }

HTH!
 

Oxan

Retired Team Member
  • Premium Supporter
  • August 29, 2009
    1,730
    1,124
    Home Country
    Netherlands Netherlands
    Hmm, that would probably be my fault. I remember that MediaPortal itself did it this way too, but your way looks saner.
     

    cederron

    Portal Member
    December 27, 2010
    16
    4
    Home Country
    Spain Spain
    Hello, I'm developing a client that uses the SwitchTVServerToChannelAnd... calls, however when i use these functions the TV Server crashes sooner or later.
    You can see the crash in the log, line 14899


    Am i using the service correctly?
    Are these "SwitchTVServerToChannelAnd..." calls meant to be called by a "remote like" type of client application or are more for streaming purposes?
    is that a known issue?

    Thanks
     

    Oxan

    Retired Team Member
  • Premium Supporter
  • August 29, 2009
    1,730
    1,124
    Home Country
    Netherlands Netherlands
    Using them for a remote-like type of client application is completely fine.

    As for the crashes, I think this is more an MP issue. Could you try it again with a clean logfile? It's a bit hard to isolate the error this way. Also, please post also the error.log file. Crash details are logged there.
     

    cederron

    Portal Member
    December 27, 2010
    16
    4
    Home Country
    Spain Spain
    umm it seems to be working ok right now.
    I'll post the logs if it fails again.

    Thanks.
     

    cederron

    Portal Member
    December 27, 2010
    16
    4
    Home Country
    Spain Spain
    Well, definitely these calls are not working completely fine. Sometimes they freeze the screen when switching channel, i have to make mediaportal windowed and then it unfreezes and other times i have the behavior in the post above.
    I'm investigating this.
     

    Users who are viewing this thread

    Top Bottom