programatic way to change channels on MP 1.15 client? (1 Viewer)

gpnash

Portal Pro
March 2, 2015
70
16
65
Linden, Michigan
Home Country
United States of America United States of America
looks like I've got a lot of work to do. just about 50% of the channel changes I did succeeded but failed (program info changed but video froze)
 

mm1352000

Retired Team Member
  • Premium Supporter
  • September 1, 2008
    21,577
    8,224
    Home Country
    New Zealand New Zealand
    I think I see the problem.

    Does your code still do this:
    https://forum.team-mediaportal.com/...annels-on-mp-1-15-client.135299/#post-1202786
    Code:
                        Dim selectChannel As TvDatabase.Channel = myitem.Tag
                        Dim tuningDetail As TvDatabase.TuningDetail = selectChannel.ReferringTuningDetail(0)
                        Dim myChannel As TvLibrary.Channels.ATSCChannel = New TvLibrary.Channels.ATSCChannel()
                        myChannel.FreeToAir = tuningDetail.FreeToAir
                        myChannel.Frequency = tuningDetail.Frequency
                        myChannel.IsRadio = tuningDetail.IsRadio
                        myChannel.IsTv = tuningDetail.IsTv
                        myChannel.MajorChannel = tuningDetail.MajorChannel
                        myChannel.MinorChannel = tuningDetail.MinorChannel
                        myChannel.Name = tuningDetail.Name
                        myChannel.NetworkId = tuningDetail.NetworkId
                        myChannel.PmtPid = tuningDetail.PmtPid
                        myChannel.Provider = tuningDetail.Provider
                        myChannel.ServiceId = tuningDetail.ServiceId
                        myChannel.TransportId = tuningDetail.TransportId

    If yes, that's where the problem is. You're not setting the [crucial!] PhysicalChannel and ModulationType properties on the myChannel object. In general such an approach is going to be very error prone, and therefore I wouldn't recommend it. Instead I'd recommend you use the provided functions such as TvBusinessLayer.GetTuningChannel() to do conversions. Strictly speaking even that is not ideal because Channels can be associated with zero or more TuningDetails. Your code, specifically:
    Code:
    Dim tuningDetail As TvDatabase.TuningDetail = selectChannel.ReferringTuningDetail(0)

    ...either assumes there will be exactly one tuning detail, or that the first tuning detail is always correct. That may be fine for your purposes (which is why I said "strictly speaking"), but it won't necessarily translate well for other people. Something to keep in mind if you were ever to decide to make your plugin available to the general public.

    P.S. I see you failed to tune 3ABN as well. Reason is the same as for Chiller: it's an SDV channel, and Charter's map is out-of-date. If you want to you can make it work in the same way that you did for Chiller.
     

    gpnash

    Portal Pro
    March 2, 2015
    70
    16
    65
    Linden, Michigan
    Home Country
    United States of America United States of America
    I'm still in a "proof of concept" mode, I was amazed to get as far as I did.
    I never expected my code to have to do the heavy lifting when it came to changing channels, but I couldn't find a tvcontrol.tuneTv(channel) command.
    My only purpose here was to enable use of a windows10 tablet to browse tv listings and be able to select the program to watch on the MP1 instance across the room.
    all of the existing efforts appear to be aimed at watching shows on the device, not making the device a more comprehensive remote.

    I tried looking at the tvplugin navigate method but I couldn't find a way to create enough of an instance of it outside of MP1.
    anyway I'm going back to the drawing board to try and collect the correct information to do tuning correctly. :) (physicalchannel and modulationtype).
    ?the only reason there'd be multiple tuning details is if there were more than one way to get to the channel?
    I've never dealt with anything other than antenna or cable and from what I've seen, in my case all of my cable tuning will be the same (eth6 6 tuners in one box) or possibly multiple usb WinTV sticks (all attached to similar antennas) that should be the same as well. I'd only have an issue if both cable and OTA stations had the same channel number, then there would be two tuningdetail records and I'd have to choose.?

    added in the two following lines and everything appears much more stable.
    when I first looked at this I didn't connect PhysicalChannel with ChannelNumber nor ModulationType with Modulation so I wasn't sure what to put there. Things make more sense if there is one tuningdetail record for each channel available on each different tuner card. I might actually be starting to understand this.
    Code:
    myChannel.PhysicalChannel = tuningDetail.ChannelNumber
    myChannel.ModulationType = tuningDetail.Modulation

    my best guess at this point Is the only errors I have left are the cable map errors.
    Next step is creating a nicer user interface than I currently have and handling the multiple ways to get to a channel issue (more than one tuning record per channel).
     
    Last edited:

    mm1352000

    Retired Team Member
  • Premium Supporter
  • September 1, 2008
    21,577
    8,224
    Home Country
    New Zealand New Zealand
    all of the existing efforts appear to be aimed at watching shows on the device, not making the device a more comprehensive remote.
    Indeed. As far as I'm aware your attempt is fairly unique.

    anyway I'm going back to the drawing board to try and collect the correct information to do tuning correctly. :) (physicalchannel and modulationtype).
    ...
    added in the two following lines and everything appears much more stable.
    when I first looked at this I didn't connect PhysicalChannel with ChannelNumber nor ModulationType with Modulation so I wasn't sure what to put there.
    Again, I strongly recommend you use the function I pointed to in my previous reply to create a correctly populated, tunable, IChannel instance from a TuningDetail. This will automatically handle all channel types properly, not just the ATSCChannel type you currently [may] have [partially] working. You shouldn't have to know or care what each channel property is connected to.

    the only reason there'd be multiple tuning details is if there were more than one way to get to the channel?
    That would be one reason. Another would be if you merged SD and HD versions of the same channel.

    ...and handling the multiple ways to get to a channel issue
    Don't feel like you have to do that if you're going to be the only person who ever uses your plugin. I was only trying to point out that your current approach has some limitations.


    A question for you: when you say "...channel information on the tv changed to channel X and program information changed...", how exactly have you made that happen?
    I ask because as far as I'm aware, the client normally wouldn't realise it if the app changed its channel. Yes, I'd expect you to be able to observe the video changing from one channel to another. However that's incidental; somewhat of a lucky co-incidence for you. There are situations in which that will not work. For example, if the channel change causes TV Server to switch to a new tuner for some reason (eg. switching between cable and antenna channels). In that case the client has to switch to a new time-shift file... but how can it know to do that if it doesn't know that it has changed channel in the first place (?). The server doesn't directly inform the client that it changed channel because it's assumed that the client requested the channel change. Obviously that doesn't apply for a channel change triggered from your app.

    So yeah, you seem to be saying that the client recognises when your app has changed its channel, whereas I wonder if that is actually the case. In my opinion this question is critical for the viability of your current approach.
     

    gpnash

    Portal Pro
    March 2, 2015
    70
    16
    65
    Linden, Michigan
    Home Country
    United States of America United States of America
    I'm looking into using gettuningdetail.

    When I've done my testing I have MP1 on the mytvhomeserver panel,
    guide information displays on the left bottom and a tv overlay on the right side.
    When my client on the tablet issues the tvcontrol.tune command the guide on the tv changes to the new information and the video stream also changes.
    I believe that because I'm using the iuser record for the client in the tune command it effects the guide on the screen of the client.

    My intention here is to both learn how MP1 and MP2 work and to develop windows 10 UWP programs to take care of some of my house hold needs. I do Insteon home automation in addition to playing with the tv and don't like generic cloud based stuff so I'm on my own a lot. I think I've got 85% of the mechanics of tuning working, if it's not just a fluke; so it's time to start on the user interface part. that's by far the harder for me to do. I'll keep you guys up to date and contribute what I can.
     

    rapaz

    New Member
    March 9, 2017
    2
    0
    62
    Home Country
    Switzerland Switzerland
    Hi gpnash,

    I'm also interested in a way to program a change of channel without MPExtended.
    Would it be possible to share your source code ?

    Thanks
     

    johanj

    MP Donator
  • Premium Supporter
  • January 31, 2009
    781
    398
    46
    Home Country
    Sweden Sweden
    I guess you mean wifiremote? Why not looknat how wifiremote did it?
     

    Users who are viewing this thread

    Top Bottom