Joined: January 13th, 2008, 4:02 pm Posts: 121 Location: Vancouver BC CANADA
ok I got the Requested By part to work... but as for the username part, how can I get that going????
I have this system where users can sign up for my site and when they register it adds to the users table in the mysql SAMDB which I am using with my Sam Broadcaster 4
I added the following to the mysql
Code:
# # Table structure for users table # DROP TABLE IF EXISTS users;
Post subject: Re: Dedication info in Mp3 title stream
Posted: February 13th, 2008, 3:43 pm
Experienced User
Joined: September 11th, 2004, 1:51 pm Posts: 328 Location: PA
Quote:
Xgeek It works great, but I still have one small problem. And that is with line feeds in the message. For every line feed Winamp displays a square box like a Wingdings font . So I need to work on a parser for Dedication_Message.
Did you ever get this part fixed? Im not sure how to "parse" in order to fix that part... Other than that, its great code....
Just need to get rid of the "wingdings font"... after so many chars it switchs to the funny lookin stuff lol
_________________ CrossFire-Radio - 100% uncensored internet radio station http://www.crossfire-radio.com DJ Fire - Owner Licensed Sam user: 2005 - Present (Sam 4.5.6) --------------------------------------------------
I recently found it necessary to add dedication info to some client's stream, so I've come up with yet another version of Xgeek's script. This one also tries to address the »control character/linefeed« problem and the damn shoutCAST »password shown« bug that they didn't fix since shoutCAST v1.9.2 …
Here goes, just in case anyone might need it:
Code:
// Requests on Stream.pal // 2008-11-12 v1.0 Moonbase // based on Xgeek's "Inject Request Dedication.pal" v0.05, 2004-11-12 PAL.LockExecution; PAL.Loop := True;
// Instantiate a Song Info object var Song: TSongInfo = TSongInfo.Create; var dedicationText: String = '';
// Check if current song is a request if ((ActivePlayer.GetSongInfo['requestID']) > 0) then begin var reqInfo: TDataSet = Query('SELECT name, msg FROM requestlist WHERE id = ' + ActivePlayer.GetSongInfo['requestID'], [], true); var requestBy: String = reqInfo['name']; var dedicationMsg : String = reqInfo['msg']; reqInfo.Free; var i: Integer; var c: String; var addStr, newTitle: String;
// clean up unwanted characters (i.e., line feeds, control characters; leave only ISO-8859-1) for i := 1 to Length(dedicationMsg) do begin c := CharAt(dedicationMsg, i); if (((CompareStr(c, ' ') >= 0) and (CompareStr(c, '~') <= 0)) or ((CompareStr(c, ' ') >= 0) and (CompareStr(c, 'ÿ') <= 0))) then dedicationText := dedicationText + c; end;
// build addistional info string addStr := ' [Request'; if (requestBy > '') then begin // we have requester's name addStr := addStr + ' von ' + requestBy; if (dedicationText > '') then // we also have a dedication addStr := addStr + ': "' + dedicationText + '"'; addStr := addStr + ']'; end else // requester didn't give his name, we won't show anonymous dedications addStr := addStr + ']';
writeln(addStr); Song['artist'] := ActivePlayer.GetSongInfo['artist']; newTitle := ActivePlayer.GetSongInfo['title'] + addStr; // force maximum length of 150 characters // (shoutCAST server shows password since v1.9.2 if > 150 characters!) if (Length(Song['artist'] + ' - ' + newTitle) > 150) then newTitle := Copy(ActivePlayer.GetSongInfo['title'] + addStr, 1, 146 - Length(Song['artist'])) + '...]'; Song['title'] := newTitle; Encoders.SongChange(Song); writeln(Song['artist'] + ' - ' + Song['title']); end;
PAL.UnlockExecution; // Release data structures Song.Free; // Wait for next song to come up PAL.WaitForPlayCount(1);
Just in case anyone needs to type this: The second character that looks like a blank in
Code:
or ((CompareStr(c, ' ') >= 0)
above is not a blank but a typed-inALT+0160! (ISO-8859-1 readable characters are #32..#127 and #160..#255.)
N.B.: The length calculation in the code is a) only needed on shoutCAST servers from v1.9.2 up (icecast seem to work correctly), and b) of course only valid if you have set title streaming in SAM to either $combine$ or $artist$ - $title$. Any adjustments should be a snap, though.
_________________ Moonbase: The Problem Solver I will not give any support for unlicensed or pirated software.
I found some potential problems with my above code:
It draws info from »ActivePlayer.whatnot« and it can happen (though seldom) that the active player actually changes while we are in the routine. Boom!
The »character cleanup« routine had a bug when no dedication was made: A »for« loop in PAL is always executed at least once, even if it goes from 1 to 0! I simply forgot about that. Haven’t done Delphi stuff for quite a while, and PAL is quite a crippled Delphi
Also, some pointers needed checking, because apparently things like »ActivePlayer.GetSongInfo« don’t always return sensible results when for instance no player is active.
So here is the improved version which seems a LOT more stable: I ran it for about 24 hours now while at the same time running several other PALs, like artist liners, request liners, stream adverts, news at top-of-the-hour, event-driven playlist rebuilds and clockwheel changes … it looks quite robust now.
Code:
// Requests on Stream.pal // 2008-11-12 v1.1 Moonbase // Originally based on Xgeek's "Inject Request Dedication.pal" v0.05, 2004-11-12 PAL.LockExecution; PAL.Loop := True;
// Instantiate Song Info objects var curSong: TSongInfo; var updSong: TSongInfo; var dedicationText: String = '';
// Save info about current song ActivePlayer might change while we work! curSong := nil; if (ActivePlayer <> nil) then curSong := ActivePlayer.GetSongInfo;
if (curSong <> nil) then begin // Something is playing, see if it is a request if (curSong['requestID'] > 0) then begin // we have a request, get requester's name and dedication text (if given) var reqInfo: TDataSet = Query('SELECT name, msg FROM requestlist WHERE id = ' + curSong['requestID'], [], true); // r/o query var requestBy: String = reqInfo['name']; var dedicationMsg: String = reqInfo['msg']; reqInfo.Free; writeln(requestBy); writeln(dedicationMsg); var i: Integer; var c: String; var addStr, newTitle: String;
// clean up unwanted characters (i.e., line feeds, control characters; leave only ISO-8859-1) i := 1; while (i <= Length(dedicationMsg)) do begin c := CharAt(dedicationMsg, i); if (((CompareStr(c, ' ') >= 0) and (CompareStr(c, '~') <= 0)) or ((CompareStr(c, ' ') >= 0) and (CompareStr(c, 'ÿ') <= 0))) then dedicationText := dedicationText + c; i := i + 1; end;
// build additional request info string addStr := ' [Hörerwunsch'; // ' [Request' if (requestBy > '') then begin // we have requester's name addStr := addStr + ' von ' + requestBy; // ' by ' if (dedicationText > '') then // we also have a dedication addStr := addStr + ': "' + dedicationText + '"'; addStr := addStr + ']'; end else // requester didn't give his name, we won't show anonymous dedications addStr := addStr + ']';
writeln(addStr); // debug updSong['artist'] := curSong['artist']; newTitle := curSong['title'] + addStr; // force maximum length of 150 characters // (shoutCAST server bug: shows password since v1.9.2 if > 150 characters!) if (Length(updSong['artist'] + ' - ' + newTitle) > 150) then newTitle := Copy(ActivePlayer.GetSongInfo['title'] + addStr, 1, 146 - Length(updSong['artist'])) + '...]'; updSong['title'] := newTitle; Encoders.SongChange(updSong); writeln(updSong['artist'] + ' - ' + updSong['title']); end; PAL.UnlockExecution; PAL.WaitForPlayCount(1); // wait until current finished end else begin // Nothing is playing, wait a while and see again PAL.UnlockExecution; PAL.WaitForTime('+00:00:15'); end;
// Release data structures curSong.Free; updSong.Free;
Of course you can remove the miscellaneous »writeln()« statements after testing …
_________________ Moonbase: The Problem Solver I will not give any support for unlicensed or pirated software.
Users browsing this forum: No registered users and 1 guest
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum