How to play radio from code (1 Viewer)

JDWestoby

MP Donator
  • Premium Supporter
  • April 9, 2008
    265
    32
    69
    Poltimore, Devon
    Home Country
    United Kingdom United Kingdom
    As part of trying to make a radio alarm clock (£200 netbook so much better than a £15 from Philips or whoever) I want to be able to turn on the Radio (or TV) from a client PC.

    I have (several) client PCs that I can listen to radio/watch TV fine just by going into the Radio or TV windows and pressing buttons. But I've not managed to do this programatically.

    Stealing the code from MediaPortal I've tried (in VB.NET for no particular reason) -

    Dim m As GUIMessage = New GUIMessage()
    m.Message = GUIMessage.MessageType.GUI_MSG_RECORDER_TUNE_RADIO
    m.Label = "BBC Radio 2"
    'TVHome.OnGlobalMessage(m)

    or

    Dim n As ChannelNavigator = New ChannelNavigator()
    Dim c As TvDatabase.Channel = n.GetChannel("BBC TWO")
    TVHome.ViewChannel(c)

    or

    'Dim b As Boolean = TVHome.ViewChannelAndCheck(c)


    But none of these seems to work. (It did play TV for half a second but even that seems to have stopped.)

    Please could anyone help in telling me how I can play (preferably a radio station) using code?


    Pretty please...:)


    (Sorry this went in MP2 - can this be moved please.)
     

    JDWestoby

    MP Donator
  • Premium Supporter
  • April 9, 2008
    265
    32
    69
    Poltimore, Devon
    Home Country
    United Kingdom United Kingdom
    Bump - bribe!

    OK, no responses, does NO-ONE know how to do this?

    Heck I could probably cobble this together using keystrokes but that is really inelegant!


    Maybe money will help....!

    £40 to MediaPortal and £10 to the person who tells me how to play a radio (and TV) channel from code on a client install using the cards/channels on a MP server.
     

    JDWestoby

    MP Donator
  • Premium Supporter
  • April 9, 2008
    265
    32
    69
    Poltimore, Devon
    Home Country
    United Kingdom United Kingdom
    Money no incentive?

    Wow, you lot must be richer than I thought.

    Does no one know how to keep the radio playing after the first second?

    I can do the first second (sending a message to the radio window [30]) but it just stops thereafter.

    Is there some sort of heartbeat I have to provide?

    I see in the TvHome that that has a heartbeat every 5 seconds, but I can't access it.
     

    JDWestoby

    MP Donator
  • Premium Supporter
  • April 9, 2008
    265
    32
    69
    Poltimore, Devon
    Home Country
    United Kingdom United Kingdom
    No offence meant

    Just had a fairly nasty message, thank you to the moderators for removing it.

    I never meant to offend anyone, but I HAVE spent over 20 SOLID hours looking at the existing code (ask my wife) and found nothing that works. As well as several hours trawling old forum messages, so I don't think I can accused of being totally idle.

    As for offering money, it isn't meant to be anything other than a token - this SI Open Source - that's why my own plugins are freely usable and open.

    All I want to do is something so simple but I got no response at all. Just silence in the breeze.

    I KNOW that this is done by people in their (ha ha) spare time so I'm not expecting massive responses but then I only need one.

    Oh, this isn't just for me either, Cheezey's iPiMP plugin would use the same code too (yes, I've been in there too).

    So sorry if anyone was offended. I like MediaPortal and have donated more than once, so I certainly want it to be more useful and usable.

    Apologies again.
     

    JDWestoby

    MP Donator
  • Premium Supporter
  • April 9, 2008
    265
    32
    69
    Poltimore, Devon
    Home Country
    United Kingdom United Kingdom
    Hows this code and 8 seconds of radio! [shock!]

    Still trying.......<grin>


    OK, now [in a plugin] have it playing for 8 seconds -using the following code!

    Bit weird as I need a copy/instance of 'Radio' [myRadio] so that I can call the Process() method, but it is invoked using the singleton TVHome! TVHome doesn't have a callable Process and g_player gives all sorts of problems so I'm doing something wrong.


    I can't believe it is this involved, all I'd like to do is call a method [TVHome.Play("BBC Radio 2")] and an equivalent stop [TVHome.Stop() maybe].


    Private Sub OnButtonX()
    myRunning = Not (myRunning) 'toggle the thread flag

    If (myRunning) Then
    myRadio = New Radio 'get the radio instance

    Dim l As TvBusinessLayer = New TvBusinessLayer()
    Dim c As Channel = l.GetChannelByName("BBC Radio 2")
    TVHome.ViewChannel(c) 'tune the radio

    'now make a thread to keep things going
    myMediaThread = New System.Threading.Thread(AddressOf MediaThreadMethod)
    myMediaThread.IsBackground = True
    myMediaThread.Start()
    Else
    'stop the radio - ignore this for the moment!
    End If
    End Sub


    Public Sub MediaThreadMethod()
    Dim p As Integer = 0
    While (MPClockPlugin.myRunning)
    If (Not (myRadio Is Nothing)) Then
    myRadio.Process()
    RemoteControl.Instance.HeartBeat(TVHome.Card().User)
    Thread.Sleep(1000)
    End If
    If (5 <= p) Then p = 0 Else p = p + 1
    End While
    End Sub


    The heartbeat doesn't seem to do anything - works for 8 seconds with or without.
    I did have the thread Process and HeartBeat on a five second boundary, as seen in the existing code [ if (p = 5) then ...], but that didin't do much either.


    One odd thing is that the media counter goes to 8 (or sometimes 9) and then back to zero - repeating. But no sound after the first 8 seconds.


    And in case I get called lazy for not reading the source - I have many, many times! in fact literally I have tried to get this to play using more than 100 different attempts. I have spent days on this.

    I'm waiting for VisualStudio 2005 (currently using 2003) >just< so I can build my own TV library function as mentioned above!


    So MediaPortal is causing me to spend serious cash too - ach well.....!
     

    Users who are viewing this thread

    Top Bottom