Jump to content

Remote Sound?


Mr Funk
 Share

Recommended Posts

Was recently asked to create a sytem that will allow a user to access and play media from another PC, all without using remote assistance.

The media sound has to come out of the NAS style device (Will be using an old system for this) that will be attached to the network.

The machine has all your general perks of a normal Pc - sound card, HDD, DVD-RW, etc. - but the machine will be hidden away so no interaction is possible.

Had a look around google and asked a few tech's that I know - but so far no dice.

Any help/input is much appreciated.

thanks

Link to comment
Share on other sites

A simple Samba share will do the trick, using either Samba on a *nix box or a shared folder/drive on a Windows box. Files can then be accessed remotely. If you need to actually play the audio on that box, try WinAmp Remote.

Link to comment
Share on other sites

i think winamp remote would do well for this since it allows you to access your music from any device that can connect to the internet and play flash files.

it basically connects to your winamp and scans all the music in your library. when you connect to the website you will be asked to login. login and it will let you get access to all the music and videos in your winamp library. it streams them via a flash player to the device, computer, game system your using.

Link to comment
Share on other sites

should the user be able to choose any song to listen to? should they be able to not only listen but download the music files as well?

if the answer to those is no then I would do streaming audio with winamp. I've done it before with an IceCast server, you make a playlist in winamp and then have it stream through the icecast server... The stream can be played in any thing that plays .m3u files (your live stream) windows media player can play them! I also have a flash player that can connect to the stream as well! ;)

this way the user cannot download the files, only hear them in the stream, also they can't change the song. It's like a radio broadcast in a way...

There is a way to convert the stream into mp3 files though ex. (streamripper)

otherwise if you wanted the user's to be able to download the songs, and choose what they want to listen to, then as moonlit suggested a shared folder will do the trick. What I like to do though is put the music files on a webserver and have a flash based web player play them in like a playlist. Then they can choose any song and it plays right off the web browser... They can also download them (actually if they're listening to it they've already downloaded it its in there browser cache)

If you'd want users to be able to listen to any song but NOT download them, then you'd have to make a more complicated flash player, like myspace.com's player for example, you can't download the mp3's unless the artist allows it. Only listen to them, They achieve that by sending a stream instead of the actual mp3 file! but like all streams they can be converted back to mp3 :) but its more secure...

Link to comment
Share on other sites

I have used MPD on linux on a remote computer to playback audio remotely. There are web based clients as well as native clients for multiple operating systems (mostly *nix systems though) for controlling MPD. I used PulseAudio as the sound server because it was the easiest to set up and was already installed on the linux distro i had.

Tutorial for using MPD with PulseAudio - http://mpd.wikia.com/wiki/PulseAudio

MPD clients - http://www.musicpd.org/clients.shtml

Link to comment
Share on other sites

hmmmm, I must not have explained my problem properly.

The sound has got to come out of the box in the cupboard as this will be hooked up to the sound system in the house.

So Winamp Remote wont do the trick as that will make the sound come out of,in this case, the laptop.

Ill make a crappy paint drawing in the morning but for now - i need to sleep.

Link to comment
Share on other sites

this way the user cannot download the files, only hear them in the stream, also they can't change the song. It's like a radio broadcast in a way...

Off topic a bit, but if you are converting them to flash, then yeah, they can't get it as an mp3 directly from the URL of the flash player, but if the flash player streams it and hides the location of the mp3, all you need to do is load wireshark before playing the mp3 file, and then you will be able to see where the mp3 is stored and you can download it. I do this all the time on most band websites that use flash mp3 players to hide their files. It also works on sites like Pandora and MySpace Music.

I can also demux an mp3 (or wav) out of Flash video and audio files using either Media Player Classic or SoTHink's Flash Decompiler if a site has embeded it in the flash file itself. :)

Link to comment
Share on other sites

hmmmm, I must not have explained my problem properly.

The sound has got to come out of the box in the cupboard as this will be hooked up to the sound system in the house.

So Winamp Remote wont do the trick as that will make the sound come out of,in this case, the laptop.

Ill make a crappy paint drawing in the morning but for now - i need to sleep.

Is this sound for multiple rooms, or just a panel in one room that uses the machine behind the cupboard? What is controlling the NAS on the network, the laptop? And how is the speaker system wired/pluged in? To the Nas sound card? Is the speaker system wired throug the home and in the walls? Do you have to install speakers?

I know, I ask a lot of questions, but I just wanted to get an idea of the layout of the house you are putting this in and what kid of hookup your are doing for the sound. RCA cables, wireless, already existing speaker system in the walls, etc.

Personally, I would just have the NAS setup with an HTTP server, plus wireless audio throughout the house using the NAS soundcard as the source and use any other pc in the house to talk to the NAS via a webpage. Start up whatever songs you want played through the NAS sound card to the speaker system (wired or wireless). Then write a little web app you can access via the webpage on the local network to start and stop the playlist, create playlists, add files, delete files, etc, etc.

Steve8x has worked out a nice front end to a php script that gives you complete control of a machine via a webpage, so it can be modded to do pretty much anything I would think, like start a media player to play the mp3's, create the playlists, and so on.

Link to comment
Share on other sites

that PHP script sounds like it would do the trick.

Any link/tutorials for it?

http://hak5.org/forums/index.php?showtopic=9662

Also, PM Steve8x so maybe you guys can collab on it more to get it working to your liking, then you can post the setup for others to see and maybe try themselves.

Link to comment
Share on other sites

there is a Remote built for VLC and Winamp, i have the copy of the winamp one on my PSP, and works great over the WiFi, ill have a look for the PC version for you.

- Edit -

Im back, here is what I've got, and theirs a few options just for winamp:

http://www.winamp.com/plugins/details/6182

http://sourceforge.net/projects/mlwww/

http://www.winamp.com/plugins/details/139139

If you want more,

http://www.winamp.com/plugins/search/?q=remote

Simple plugin search on Winamp comes up with lots.

Link to comment
Share on other sites

@Mr Funk great to see you solved your problem!

@digip Does that still work? getting the URL to the song on myspace and downloading it? I thought you USED to be able to do that but they changed it so you can't anymore...

By randomly changing the name of the mp3 file stored on the server. I used to do it to but you only had like a 10 second window to be downloading the file, if you were too slow then the file would already have its name changed and you'd get a file not found error...

I'm guessing you haven't tried this recently? To prove you wrong I created a sample program! it sends a packet to mediaservices.myspace.com with a friendID to get the xml file which holds the song playlist info, which has fields specifying the url of the song to download... it seems as if the url always gives a 404 error, not even allowing that 10 second window anymore! :(

its a DevCPP project. Specify a friend ID and click "Get Songs" it will display the songs the music myspace page has in the list box. Then select a song and click download and it will find which url is for the selected song and load the url into your default web browser for download... sad thing is, you get a 404: file not found error no matter how fast you click download !!!

So if I'm doing it wrong please let me know how I can fix my program to be able to get it to work, try it with your wireshark again and let me know your results... else I'll have to figure out how to convert an RMTP stream into a mp3 file...

myspacejuke.png

404.png

project files:

http://popeax.com/myspacejuke.zip

source:

//Myspace Juke v1.0 - downloads songs from myspace
//even when the download link is not available
//by Steve8x
#include <winsock2.h>
#include <windows.h>
#include <stdio.h>
#include "EasyControls.h"
#include "EasySockets.h" // Simple Winsock Classes

char* HOST = "mediaservices.myspace.com";
char* HEADER = "GET /services/media/musicplayerxml.ashx?b=%s"; //friendID will be in place of '%s'

void WorkerThread(void);
void DownloadThread(void);
int ListSongs(void);
int cmp(char*, char*, int);
char* head = 0;
char* postdata = 0;
char* recvdata = 0;
char* songs = 0;
char dbg[200];

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmd, int nCmdShow)
{
    MSG Msg;
    WNDCLASSEX wc;
    hInst = hInstance;
       
    wc.cbSize = sizeof(WNDCLASSEX);
    wc.hInstance = hInstance;
    wc.lpszClassName = "MyspaceJuke_Class";
    wc.lpfnWndProc = WndProc;
    wc.style = CS_DBLCLKS;
    wc.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(101));
    wc.hIconSm = LoadIcon(hInst, MAKEINTRESOURCE(101));
    wc.hCursor = LoadCursor(0, IDC_ARROW);
    wc.lpszMenuName = NULL;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;          
    wc.hbrBackground = (HBRUSH)GetStockObject(0);
    
    RegisterClassEx(&wc);
    
    // Initialize common controls library!
    InitCommonCtrls(); // to make sure you can see the controls!
    
    //Create the window
    hwnd = CreateWindowEx(0, "MyspaceJuke_Class", "MyspaceJuke", WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_CLIPSIBLINGS,
            CW_USEDEFAULT, CW_USEDEFAULT, 290, 150, HWND_DESKTOP, 0, hInstance, 0);
    
    CreateTextEx(hwnd, "FriendID:", 1, 1, 60, 22, 200);
    fID = CreateEditEx(hwnd, 0, 0, 0, 65, 1, 135, 22, 400);
    CreateButtonEx(hwnd, "Get Songs", 202, 1, 80, 22, 420);
    
    CreateTextEx(hwnd, "Select Song:", 1, 30, 100, 20, 201);
    song = CreateDropDownEx(hwnd, 0, 1, 50, 200, 100, 300);
    CreateButtonEx(hwnd, "Download", 202, 50, 80, 22, 421);
    
    CreateTextEx(hwnd, "© 2008 Steve8x", 85, 90, 150, 22, 202);
    
    songs = (char*)malloc(5000);
    recvdata = (char*)malloc(100000);

    //Show our window
    ShowWindow(hwnd, nCmdShow);
    UpdateWindow(hwnd);

    //Init winsock 2.2
    WSADATA wsaData = {0};
    WSAStartup(MAKEWORD(2, 2), &wsaData);
    
    while(GetMessage(&Msg, 0, 0, 0))
    {
        TranslateMessage(&Msg);
        DispatchMessage(&Msg);
    }
    return Msg.wParam;
}
    

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {   
        case WM_COMMAND:
            if(wParam == 420) //Get Songs button pressed
            {
                CreateThread(0, 0, (LPTHREAD_START_ROUTINE)&WorkerThread, 0, 0, 0);
            }
            if(wParam == 421) //Download button pressed
            {
                CreateThread(0, 0, (LPTHREAD_START_ROUTINE)&DownloadThread, 0, 0, 0);
            }
            break;
            
        case WM_LBUTTONDOWN: //I do this for all my app's I like dragging the window from anywhere
            SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, lParam);
            break;
                            
        case WM_CTLCOLORSTATIC:
            SetBkMode((HDC)wParam, TRANSPARENT);
            return (LRESULT)GetStockObject(WHITE_BRUSH);
            break;
            
        case WM_CLOSE:
            free(recvdata);
            free(songs);
            WSACleanup();
            PostQuitMessage(0);
            break;
            
        default:  
            return DefWindowProc (hWnd, message, wParam, lParam);
    }
    return 0;
}
    
    
void WorkerThread()
{
    xClient* cli = new xClient;
    head = (char*)malloc(1000);
    postdata = (char*)malloc(10000);
    
    //malloc does not init memory to zero
    ZeroMemory(head, 1000);
    ZeroMemory(postdata, 10000);
    ZeroMemory(recvdata, 100000);
    
    GetWindowTextA(fID, dbg, 101);
    sprintf(head, HEADER, dbg);
    sprintf(postdata, "%s HTTP/1.1\r\nAccept: */*\r\nConnection: close\r\nHost: %s\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)\r\n\r\n", head, HOST);
    
    cli->ConnectToServer(HOST, 80);
    sendx(cli->serversock, postdata, strlen(postdata));
    recvx(cli->serversock, recvdata, 100000);
    cli->Close();
    
    OutputDebugString(recvdata);
    int numsongs = ListSongs();
    
    sprintf(dbg, "number of songs = %i", numsongs);
    OutputDebugString(dbg);
    
    SendMessage(song, CB_SETCURSEL, 0, 0);
    
    //Clean up
    delete cli;
    free(head);
    free(postdata);
    ExitThread(0);
}

int ListSongs() // i changed to using the cmp function i created so i could compare more than 32 bits at a time
{
    int numsongs = 0;
    DWORD i = 0;
    char* songname = (char*)malloc(200);
    char* title = recvdata;
    
    ZeroMemory(songname, 200);
    ZeroMemory(songs, 5000);
    
    SendMessage(song, CB_RESETCONTENT, 0, 0); // clears the list box
    
    nextsong:
    //while(*(DWORD*)title != 0x6C746974) // 'titl'
    while(cmp(title, "title=\"", 7) == 0) // locate song title
    {
        //if(*(DWORD*)titl == 0x72702F3C) // '</pr'
        if(cmp(title, "</playlist>", 11) == 1)
        {
            //end of songs in xml file reached
            SendMessage(song, CB_SHOWDROPDOWN, 1, 0);
            free(songname);
            return numsongs;
        }
            
        title++;
    }
    title += 7; // get past 'title="'
    
    int stringsize = 0;
    char* endofstring = title;
    
    //get string size by counting the characters until the next double quote
    while(*(BYTE*)endofstring != 0x22) // '"'
    {
        endofstring++;
        stringsize++;
    }
    
    //copy song name into string array
    memcpy(songname, title, stringsize);
    strcpy(&songs[i], songname);
    //zero 'songname' temporary buffer in prep for next song
    ZeroMemory(songname, 200);
    
    SendMessage(song, CB_ADDSTRING, 0, (LPARAM)&songs[i]);
    
    i += (stringsize + 1); //calculate next string offset
    numsongs++;
    
    goto nextsong;
}

void DownloadThread()
{
    char* downloadurl = (char*)malloc(1000);
    char* songurl = recvdata;
    LRESULT selectedsong;
    
    ZeroMemory(downloadurl, 1000);
    
    selectedsong = SendMessage(song, CB_GETCURSEL, 0, 0);
    selectedsong += 1;
    
    while(selectedsong != 0) // locate url of song selected
    {
        //while(*(DWORD*)songurl != 0x6C727564) // 'durl'
        while(cmp(songurl, "durl=\"", 6) == 0)
        {
            songurl++;
        }
        songurl++;
        selectedsong--;
    }
    
    songurl += 5; // get past 'url="'
    
    int urlsize = 0;
    char* endofstring = songurl;
    
    while(*(BYTE*)endofstring != 0x22) // '"'
    {
        endofstring++;
        urlsize++;
    }
    
    memcpy(downloadurl, songurl, urlsize);
    
    //download the file in your default web browser
    ShellExecute(0, "open", downloadurl, 0, 0, SW_SHOWNORMAL);
    
    free(downloadurl);
}
    
int cmp(char* str1, char* str2, int strsize) // compare non null terminated strings by specifying size
{
    for(int i = 0; i < strsize; i++)
    {
        //if(*(BYTE*)&str1[i] != *(BYTE*)&str2[i]) // == same as line below
        if(str1[i] != str2[i])
        {
            //strings not equal
            return 0;
        }
    }
    //strings are equal
    return 1;
}

Link to comment
Share on other sites

I'm guessing you haven't tried this recently?

Um, just ripped some new metallica the other day, so it still works. Few things, you have to set your browser to allow referrer for *.myspace.com as well as give the url with the hash to the browser WHILE listening to the song from he same page.

Here are the steps I use. (And even if a site doesn't end in .mp3, there are ways around this, but more on that later)

1. Open wiershark and start logging packets.

2. Navigate to the MySpace page with the song you want.

3. Click play on the song you want and then search wireshark for .mp3 (CTRL + F, then STRING .mp3)

4. It should move to the packet containing the file. Right click and select "Follow TCP Stream" and you will see something like this

GET /34/std_530a63994c8fd840e6131ed4e6f9e847.mp3?bandid=154414319&songid=45424398&token=1220361122_b5d37d847d0c542b3c43738
495bd87a1&p=aHR0cDovL2NhY2hlMDUtbXVzaWMwMS5teXNwYWNlY2RuLmNvbS8zNC9zd
GRfNTMwYTYzOTk0YzhmZDg0MGU2MTMxZWQ0ZTZmOWU4NDcubXAz&a=0 HTTP/1.1

User-Agent: Opera/9.52 (Windows NT 5.1; U; en)

Host: cache05-music01.myspacecdn.com

Accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1

Accept-Language: en-US,en;q=0.9

Accept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1

Accept-Encoding: deflate, gzip, x-gzip, identity, *;q=0

Referer: http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendid=154414319&MyToken=88c0a94c-3969-44a6-bf0a-6740786a2110

Connection: Keep-Alive

5. Get the url from the above packet:

http://cache05-music01.myspacecdn.com/34/s...DcubXAz&a=0

6. Paste it in your browser while the song is still playing, and you are on the same webpage. It will prompt you to download the file. If it doesn't redo the steps, but make sure yoru browser does not block the referrer or any cookies it tries to set or you will get a 404 not found!!

7. Save, and enjoy!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...