home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
Development
General Development (no feature request here!)
How to play radio from code
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="JDWestoby" data-source="post: 696961" data-attributes="member: 72093"><p><strong>Hows this code and 8 seconds of radio! [shock!]</strong></p><p></p><p>Still trying.......<grin></p><p></p><p></p><p>OK, now [in a plugin] have it playing for 8 seconds -using the following code!</p><p></p><p>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.</p><p></p><p></p><p>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].</p><p></p><p></p><p> Private Sub OnButtonX()</p><p> myRunning = Not (myRunning) 'toggle the thread flag</p><p></p><p> If (myRunning) Then</p><p> myRadio = New Radio 'get the radio instance</p><p></p><p> Dim l As TvBusinessLayer = New TvBusinessLayer()</p><p> Dim c As Channel = l.GetChannelByName("BBC Radio 2")</p><p> TVHome.ViewChannel(c) 'tune the radio</p><p></p><p> 'now make a thread to keep things going</p><p> myMediaThread = New System.Threading.Thread(AddressOf MediaThreadMethod)</p><p> myMediaThread.IsBackground = True</p><p> myMediaThread.Start()</p><p> Else</p><p> 'stop the radio - ignore this for the moment!</p><p> End If</p><p> End Sub</p><p></p><p></p><p> Public Sub MediaThreadMethod()</p><p> Dim p As Integer = 0</p><p> While (MPClockPlugin.myRunning)</p><p> If (Not (myRadio Is Nothing)) Then</p><p> myRadio.Process()</p><p> RemoteControl.Instance.HeartBeat(TVHome.Card().User)</p><p> Thread.Sleep(1000)</p><p> End If</p><p> If (5 <= p) Then p = 0 Else p = p + 1</p><p> End While</p><p> End Sub</p><p></p><p></p><p>The heartbeat doesn't seem to do anything - works for 8 seconds with or without. </p><p>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.</p><p></p><p></p><p>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.</p><p></p><p></p><p>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.</p><p></p><p>I'm waiting for VisualStudio 2005 (currently using 2003) >just< so I can build my own TV library function as mentioned above!</p><p></p><p></p><p>So MediaPortal is causing me to spend serious cash too - ach well.....!</p></blockquote><p></p>
[QUOTE="JDWestoby, post: 696961, member: 72093"] [b]Hows this code and 8 seconds of radio! [shock!][/b] 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.....! [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
Development
General Development (no feature request here!)
How to play radio from code
Contact us
RSS
Top
Bottom