Hello nuns and monks,

As you can see in my read an mp3 stream and save tracks using icy-metaint (ICY protocol) i was able to succesfully read an mp3 stream cutting it at icy-mataint occurences and also able to (possibly) skip advertisements.

Now, and was my original goal, I want to reproduce this stream and I found that all modules I investigated need a file while I have a stream.

If you take a look at my above mentioned code, I just read froma a socket by chunk and, in the read_stream sub, I get $buf populated with just the music (no metadata) and I pass $buf to the write_stream sub.

So my original idea was to push all these $buf into something like a big cache and have some other sub shifting such cache and play each chunk..

Some help on how to implement it? ;=) I'd like a perl solution, portable as much as it is possible (you know I mainly work on win32..): so using external programs as'mpeg123' and similar are not what i'm searching for. Until now I have mumbled the following:

1 - tempfile)As all modules (and programs too) I investigated, needs to be feed with a file, it will be possible to have a temp file and append to it. It's not a optimal solution: how to know how much of the the neverending file was already played? how to rotate it?

2 - reproxing) Once i have $buf i can re-stream them using a local server listening on 127.0.0.1 and launch an external program (like vlc or you preferred one) to connect to such stream to play it. This is an overcomplicated solution..

The only module I found that seems able to play music contained in a variable is SDL::Mixer::Music that can receive data via SDL::RWOps but I was not able to make it to run. Examples in this direction will be appreciated. I suppose SDL has some limitation playing mp3 on windows (missing libraries?) I had success only playing wav files (not varibles with wav inside).

Form the SDL::Mixer::Music documentation

use SDL; use SDL::Mixer; use SDL::Mixer::Music; use SDL::RWOps; my $rwops = SDL::RWOps->new_const_mem( $scalar_holding_music ); my $music = SDL::Mixer::Music::load_MUS_RW( $rwops );

Any help and suggestion will be very much appreciated

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

In reply to play mp3 stream (music) portably by Discipulus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.