Internet Radio (1 Viewer)

burdell1

Portal Pro
June 8, 2006
64
0
Instead of streaming the title of the song that is currently playing, the port number used is statically displayed.

I second that one.... also, I am curious how to listen radio stations as well that are on the internet (like local radio stations that don't use shoutcast.) How can i do this?
 

arjay

Portal Pro
April 25, 2006
87
0
Coin, Spain
Make an InternetRadio Directory, i.e. My Documents/My Music/Internet Radio.
Go to www.shoutcast.com, and pick your style of music.
Right Click on the Tune-In button and save the download file shortcut.
Save it in your InternetRadio Directory, renaming it accordingly, i.e. Jazz.pls.
Start MediaPortal, Goto: Tools, Options [F2], MyRadio.
Set the StreamList Folder to your InternetRadio Directory
No Off-Air Radio Stations need to be setup for this to function.
Close the Setup dialog boxes.

Sorry to be so feeble, but I am trying to setup internet radio following this guide and have got stuck at the point above.

Now I can't find "Tools/Options/Myradio in either MP or mediaportal setup. I see this thread is quite old - has this section been changed in anyway or am I just being thick?

Thnx

RJ
 

deppeler

Portal Pro
June 23, 2006
79
0
burdell1 said:
Instead of streaming the title of the song that is currently playing, the port number used is statically displayed.

I second that one.... also, I am curious how to listen radio stations as well that are on the internet (like local radio stations that don't use shoutcast.) How can i do this?

Does anybody have this working?
 

Spagbol

Portal Member
June 23, 2006
32
0
Been mulling over the internet radio display problem so I re-wrote the VB6 code I wrote for parsing Station name, track title and bitrate from a shoutcast stream and compiled it into an activex dll. This is in the hope that it's more use to someone as I suspect it can be imported or used quite easily in a C# application (I haven't the time to figure out how to actually code it in C#). If it doesn't work in C#, then sorry!

The dll has 2 publicly available methods. 1 called Tune which requires the server IP as a String, and the port as a Long. The VB syntax is object.Tune IPaddress, Port.
The other is Stop and just closes the connection to the station (object.Stop).
The results are returned in global strings named Bitrate, Station and TrackTitle.
The dll listens to the data stream once opened and so updates the strings when the station changes the data (e.g. track title) but I cannot find a way of getting the dll to automatically resend the data as I don't think you can specify runtime paths to send variables to from a module. The easy way round is to just set up a timer to fetch the strings from the host application every 200 milliseconds or so.

You can download the dll and sample VB project to show how it works here. It's not pretty to look at but functional and only 18 lines of code including the timer to update the labels.
Don't forget to register and reference the dll before trying to run the app from source code.

Here's hoping it's of use!!
 

CHACAL

Portal Member
August 16, 2006
13
0
Melbourne
Love this plugin / add-on / what-ever-its-called...

I have added a heap of internet radion stations, internet TV stations, web cams... everything was hunky-dory and i was fast falling in love with Media Portal...

then one day i woke up and the "video" for streaming Internet TV doesn't work, likewise the video for streaming web cams... i still get audio for the internet TV, but no visual.

thinking it was probably a codec failure / corruption / hicup / full moon, i installed ffdshow and whallah! back to perfect "i love media portal" performance...

then one day i woke up and the "video" for streaming internet TV blah blah blah... not working again!!!

whats going on here? any suggestion guys?

Thanks
 

Spagbol

Portal Member
June 23, 2006
32
0
Well, after a brief chat with the devs in which I was (quite rightly) told that only C# source could be used, I PM'd rtv the code for the dll, and the original VB program in the hopes he could port it to C#.
That was a while back and have heard nothing since. A post in another thread prompted me to re-look at the problem and I have a hack/workaround.

As mentioned before, I don't program in C# but wrote a program in VB6 to do the work and worked out how to integrate it.
A couple of points to bear in mind... many shoutcast streams don't include artist, title etc. information; the formatting of the C# code isn't perfectly neat; shoutcast data is often streamed up to 15 seconds before the audio and so changes of track don't always coincide with the display - this is not a bug; this was coded and tested with version 0.2.2.0 using the internal audio player only; and lastly, for obvious reasons, this will not work if 'MediaPortal always on top" is checked (might look for a solution to this one...)

Changes needed...
1) Changes to GUIRadio.cs
2) Changes to g-player.cs
3) Put shoutcastinfo.exe and shoutcastinfo.ini in the root of your MediaPortal install (usually C:\Program files\Team Mediaportal\MediaPortal)

Lastly, you need MSWinSck.ocx registered on your machine.

1) In GUIRadio.cs:

change void OnClick(int itemIndex) to

Code:
void OnClick(int itemIndex)
      {
              GUIListItem item = GetSelectedItem();

              if (item == null) return;
              if (item.IsFolder)
              {
                  if (currentPlayList != null)
                  {
                      currentPlayList = null;
                  }
                  selectedItemIndex = -1;
                  LoadDirectory(item.Path);
              }
              else
              {

                  System.Diagnostics.Process proc = new System.Diagnostics.Process();

                  string shoutcastpath = item.Path;
                  string shoutcastfirstfourletters = (shoutcastpath.Substring(0, 4));
                  if (shoutcastfirstfourletters == "http")
                  {
                      TextWriter tw = new StreamWriter("tempshoutcast.txt");
                      tw.WriteLine(shoutcastpath);
                      tw.Close();
                      proc.EnableRaisingEvents = false;
                      proc.StartInfo.FileName = "shoutcastinfo";
                      proc.Start();
                  }
                     Play(item);
                 GUIPropertyManager.SetProperty("#selecteditem", item.Label);
              }
          }

and change void Play(GUIListItem item) to
Code:
   void Play(GUIListItem item)
    {                

        if (MediaPortal.Util.Utils.IsPlayList(item.Path))
      {
        currentPlayList = new PlayList();
        IPlayListIO loader = PlayListFactory.CreateIO(item.Path);
        loader.Load(currentPlayList, item.Path);
        if (currentPlayList.Count == 1)                    

        {           
                      System.Diagnostics.Process proc = new System.Diagnostics.Process();
                      string shoutcastpath = item.Path;
                      TextWriter tw = new StreamWriter("tempshoutcast.txt");
                      tw.WriteLine(shoutcastpath);
                      tw.Close();
                      proc.EnableRaisingEvents = true;
                      proc.StartInfo.FileName = "shoutcastinfo";
                      proc.Start();


          // add current directory 2 playlist and play this item
          string strURL = currentPlayList[0].FileName;
          currentPlayList = null;
          FillPlayList();
          playlistPlayer.Play(strURL);
          return;
        }
        if (currentPlayList.Count == 0)
        {
          currentPlayList = null;
        }
        LoadDirectory(currentFolder);
      }
      else
      {
        if (currentPlayList != null)
        {
          // add current playlist->playlist and play selected item
          string strURL = item.Path;
          FillPlayList();
          playlistPlayer.Play(strURL);
          return;
        }

        // add current directory 2 playlist and play this item
        RadioStation station = item.MusicTag as RadioStation;
        FillPlayList();

        PlayList playlist = playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC_TEMP);
        for (int i = 0; i < playlist.Count; ++i)
        {
          PlayListItem playItem = playlist[i];
          if (playItem.Description.Equals(item.Label))
          {
            playlistPlayer.Play(i);
            break;
          }
        }  
      }        
    }

These changes will write a temporary text file containing either the http path or the .pls file of the radio station.
It will then launch shoutcastinfo.exe that I wrote which will parse the correct info from the text file, connect to the stream and show the relevant data.

2) In g_player.cs

add using System.IO; at the top...

And change public static void Stop() to

Code:
public static void Stop()
    {
      if (_player != null)
      {
        Log.Info("g_Player.Stop()");
        OnStopped();
        GUIGraphicsContext.ShowBackground = true;
        _player.Stop();
        if (GUIGraphicsContext.form != null)
        {
          GUIGraphicsContext.form.Invalidate(true);
        }
        GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_PLAYBACK_STOPPED, 0, 0, 0, 0, 0, null);
        GUIWindowManager.SendThreadMessage(msg);

        GUIGraphicsContext.IsFullScreenVideo = false;
        GUIGraphicsContext.IsPlaying = false;
        GUIGraphicsContext.IsPlayingVideo = false;
        CachePlayer();

        TextWriter tw = new StreamWriter("tempshoutcast.txt");
        tw.WriteLine("Stopped");
        tw.Close();
      }
    }

This will unload the module when shoutcast playback is stopped, through any means including exiting MediaPortal.

3) Place the shoutcastinfo.exe and .ini files in your MediaPortal directory. The files can be downloaded from here.

The way the information box displays can be controlled by editing the ini file - font size, width of the module, height of the module and positioning on screen. You will have to experiment with those for your system!
Screenshots here and here.

I have a 10 day old baby so not much spare time, but any problems I will try and sort out. Works fine for me :D
 

Spagbol

Portal Member
June 23, 2006
32
0
OK, I've updated the .exe and .ini files for more customizability(!).
Available here.

You can now set font size, font style, font colour, background colour, border colour, set border on or off, border size, width, height and position of the module, set the scroll speed and turn the scroll on or off all from the ini file.
Screenshot with foul colours and a wide border here.

With a bit of careful positioning and settings you can make it seem part of MediaPortal like here.

For those of you who don't want to mess with SVN code, here are the compiled files.
Make sure you backup the originals just in case...
Core.dll which goes in your root MediaPortal directory
WindowsPlugins.dll which goes in MediaPortal/Plugins/Windows
Remember, they are from SVN code so not guaranteed stable.

If you try it and can't see the module, check the following things:
Check MP isn't always on top
Check the Top and Left settings in the ini file - you may be showing it off screen
 

Users who are viewing this thread

Top Bottom