pär Posted January 7, 2008 Posted January 7, 2008 (edited) Can anyone provide me with a short code snippet(pref in c#) that shows available channels? I have rather limited experience developing in c#, and now i'm stuck. I've tried following to get a channel list: object obj; DVBViewer.ChannelManager.GetChannelList(out obj); Console.WriteLine(obj.ToString()); The list seems empty. DVBViewer is running and everything seems fine. Edited January 7, 2008 by pär Quote
pär Posted January 7, 2008 Author Posted January 7, 2008 did u connect to DVBViewer before ? yes, using: DVBViewer = (DVBViewer)System.Runtime.InteropServices.Marshal.GetActiveObject("DVBViewerServer.DVBViewer"); and DVBViewer is running. Apparently, DVBViewer.ChannelManager has a property named "Item"(according to the docs). But my instance of DVBViewer won't recognize this property. It does, however, find the property "Count". Quote
olixelle Posted January 7, 2008 Posted January 7, 2008 first i'm not sure that u should use out argument for the parameter (out implies that parameter already contains a value i think) second, chanlist is a 2 dimension array so the tostring method may not work: did u try to browse the object Quote
pär Posted January 7, 2008 Author Posted January 7, 2008 first i'm not sure that u should use out argument for the parameter (out implies that parameter already contains a value i think)second, chanlist is a 2 dimension array so the tostring method may not work: did u try to browse the object Oh. Well, how do i browse it? Thanks for your help. Quote
diposo Posted March 27, 2009 Posted March 27, 2009 I used the following to get the channel list: IDVBViewer dvbServer = (IDVBViewer)Marshal.GetActiveObject("DVBViewerServer.DVBViewer"); IChannelCollection chnCol = dvbServer.ChannelManager; for (int k = 0; k < chnCol.Count; k++) { System.Console.WriteLine(chnCol[k].Name); } Quote
Springveldt Posted March 29, 2009 Posted March 29, 2009 IDVBViewer m_DvbViewer = null; try { // Try and get the running instance, a COMException is thrown if the class name is not known m_DvbViewer = (IDVBViewer)Marshal.GetActiveObject("DVBViewerServer.DVBViewer"); } catch (COMException) { if (MessageBox.Show("DVBViewer is currently not running.\r\nDo you wish to start it?", "Start DVBViewer", MessageBoxButtons.YesNo) == DialogResult.Yes) { // DVBViewer isn't running, so start it m_DvbViewer = new DVBViewer(); } } finally { if (m_DvbViewer != null) { object[,] oDvbChannelArray = null; object oDvbChannelList = new object(); m_DvbViewer.ChannelManager.GetChannelList(out oDvbChannelList); oDvbChannelArray = (object[,])oDvbChannelList; } } You could declare the size of the channel array saving the cast if you wanted to. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.