programatic way to change channels on MP 1.15 client? | Page 3

Discussion in 'MediaPortal 1 Talk' started by gpnash, October 26, 2016.

  1. gpnash

    gpnash Portal Pro

    Joined:
    March 2, 2015
    Messages:
    63
    Likes Received:
    5
    Gender:
    Male
    Occupation:
    retired systems programmer
    Location:
    Linden, Michigan
    Ratings:
    +10 / 0
    Home Country:
    United States of America United States of America
    Show System Specs
    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)


     
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. mm1352000
    • Team MediaPortal

    mm1352000 Development Group

    Joined:
    September 1, 2008
    Messages:
    21,515
    Likes Received:
    4,723
    Ratings:
    +8,189 / 17
    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 (Text):
    1.                     Dim selectChannel As TvDatabase.Channel = myitem.Tag
    2.                     Dim tuningDetail As TvDatabase.TuningDetail = selectChannel.ReferringTuningDetail(0)
    3.                     Dim myChannel As TvLibrary.Channels.ATSCChannel = New TvLibrary.Channels.ATSCChannel()
    4.                     myChannel.FreeToAir = tuningDetail.FreeToAir
    5.                     myChannel.Frequency = tuningDetail.Frequency
    6.                     myChannel.IsRadio = tuningDetail.IsRadio
    7.                     myChannel.IsTv = tuningDetail.IsTv
    8.                     myChannel.MajorChannel = tuningDetail.MajorChannel
    9.                     myChannel.MinorChannel = tuningDetail.MinorChannel
    10.                     myChannel.Name = tuningDetail.Name
    11.                     myChannel.NetworkId = tuningDetail.NetworkId
    12.                     myChannel.PmtPid = tuningDetail.PmtPid
    13.                     myChannel.Provider = tuningDetail.Provider
    14.                     myChannel.ServiceId = tuningDetail.ServiceId
    15.                     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 (Text):
    1. 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.
     
  4. gpnash

    gpnash Portal Pro

    Joined:
    March 2, 2015
    Messages:
    63
    Likes Received:
    5
    Gender:
    Male
    Occupation:
    retired systems programmer
    Location:
    Linden, Michigan
    Ratings:
    +10 / 0
    Home Country:
    United States of America United States of America
    Show System Specs
    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 (Text):
    1.  
    2. myChannel.PhysicalChannel = tuningDetail.ChannelNumber
    3. myChannel.ModulationType = tuningDetail.Modulation
    4.  
    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: December 13, 2016
  5. mm1352000
    • Team MediaPortal

    mm1352000 Development Group

    Joined:
    September 1, 2008
    Messages:
    21,515
    Likes Received:
    4,723
    Ratings:
    +8,189 / 17
    Home Country:
    New Zealand New Zealand
    Indeed. As far as I'm aware your attempt is fairly unique.

    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.

    That would be one reason. Another would be if you merged SD and HD versions of the same channel.

    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.
     
  6. gpnash

    gpnash Portal Pro

    Joined:
    March 2, 2015
    Messages:
    63
    Likes Received:
    5
    Gender:
    Male
    Occupation:
    retired systems programmer
    Location:
    Linden, Michigan
    Ratings:
    +10 / 0
    Home Country:
    United States of America United States of America
    Show System Specs
    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.
     
  7. rapaz

    rapaz New Member

    Joined:
    March 9, 2017
    Messages:
    2
    Likes Received:
    0
    Gender:
    Male
    Ratings:
    +0 / 0
    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
     
  8. johanj
    • Premium Supporter

    johanj Well-Known Member

    Joined:
    January 31, 2009
    Messages:
    781
    Likes Received:
    270
    Gender:
    Male
    Ratings:
    +398 / 1
    Home Country:
    Sweden Sweden
    I guess you mean wifiremote? Why not looknat how wifiremote did it?
     
  9. rapaz

    rapaz New Member

    Joined:
    March 9, 2017
    Messages:
    2
    Likes Received:
    0
    Gender:
    Male
    Ratings:
    +0 / 0
    Home Country:
    Switzerland Switzerland
    Wifiremote uses MPExtended, I think ...
     
Loading...

Users Viewing Thread (Users: 0, Guests: 0)

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice
  • About The Project

    The vision of the MediaPortal project is to create a free open source media centre application, which supports all advanced media centre functions, and is accessible to all Windows users.

    In reaching this goal we are working every day to make sure our software is one of the best.

             

  • Support MediaPortal!

    The team works very hard to make sure the community is running the best HTPC-software. We give away MediaPortal for free but hosting and software is not for us.

    Care to support our work with a few bucks? We'd really appreciate it!