Results 1 to 4 of 4

Thread: How To Implement Audio Streaming??

  1. #1
    Join Date
    Sep 2010
    Posts
    3

    How To Implement Audio Streaming??

    Hi,

    Please Help me out in implementing my Application which can play an audio file(incomplete) present in my Desktop.

    Explanation:

    I have a file "TestSource.mp3"
    In my application i create a new file "TestDest.mp3" and write the first 50KB of data from "TestSource.mp3" using windows filesys APIs.

    Now I want to start playing the data in TestDest.mp3 which is been copied.
    While this data is been played, I want to append the remaning data.
    In this way the whole song should be played.

    If it is not possible to implement using this method, Is ther any other method.

    Thanks,
    ajay

  2. #2
    Join Date
    Apr 2008
    Posts
    240

    Re: How To Implement Audio Streaming??

    Hello,
    It would be great if you can post the code or the important part of the code here, this would make easy to solve your problem. Also, you have not mentioned the error what you are getting. I think the best way would be to buffer first and then copy the complete song to the destination audio file. Though I can not predict any thing before checking you code.

  3. #3
    Join Date
    Sep 2010
    Posts
    3

    Re: How To Implement Audio Streaming??

    I am Using DirectShow for playing the file. But not happening.
    When I try to open the file for writing the second set of bytes, error I am getting as the file is in use for playing.

    Code is given below.
    This code is just a sample i ave created for illustrating my requirement. It has itz own limitations.


    int main(int argc, char* argv[])
    {
    IGraphBuilder *pGraph = NULL;
    IMediaControl *pControl = NULL;
    IMediaEvent *pEvent = NULL;
    FILE *pFileDest = NULL;
    FILE *pFileSource = NULL;
    char szBuf[50000] = {0};

    HRESULT hr = CoInitialize(NULL);
    if (FAILED(hr))
    {
    printf("ERROR - Could not initialize COM library");
    return;
    }

    hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
    IID_IGraphBuilder, (void **)&pGraph);
    if (FAILED(hr))
    {
    printf("ERROR - Could not create the Filter Graph Manager.");
    return;
    }

    hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
    hr = pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);
    pFileDest = fopen("E:\\Music\\Copy of Let The Music Play.mp3","wb+");

    pFileSource = fopen("E:\\Music\\Copy of Let The Music Play_Source.mp3","r");
    fread(szBuf,sizeof(char),45000,pFileSource);
    fwrite(szBuf,sizeof(char),45000,(FILE*)pFileDest);
    fclose((FILE*)pFileDest);
    pFileDest = NULL;

    hr = pGraph->RenderFile(L"E:\\Music\\Copy of Let The Music Play.mp3", NULL);
    if (SUCCEEDED(hr))
    {
    hr = pControl->Run();
    if (SUCCEEDED(hr))
    {
    long evCode;


    pFileDest = fopen("E:\\Music\\Copy of Let The Music Play.mp3","a+");
    /*This fopen fails*/

    fwrite(szBuf,sizeof(char),45000,(FILE*)pFileDest);

    pEvent->WaitForCompletion(INFINITE, &evCode);

    }
    }
    pControl->Release();
    pEvent->Release();
    pGraph->Release();
    CoUninitialize();
    }
    Thanks
    ajay

  4. #4
    Join Date
    May 2009
    Posts
    637

    Re: How To Implement Audio Streaming??

    You can use the filter wavdest SDK (build it), and associate it with the filter FileWriter for the destination file. And if the same is for an video support then it takes AVI encoder. I had captured the video and I save a file. Avi and the sound corresponding to the video file in a wav. Tell your compiler to ignore the library and the compilation will be fine.

Similar Threads

  1. Replies: 9
    Last Post: 07-07-2012, 10:46 AM
  2. How to delay Streaming Audio?
    By LanKush in forum Technology & Internet
    Replies: 4
    Last Post: 03-06-2011, 07:18 PM
  3. WIFI and streaming audio
    By milf in forum Networking & Security
    Replies: 3
    Last Post: 18-09-2009, 11:14 AM
  4. Streaming audio
    By sdwivedi in forum Windows Software
    Replies: 3
    Last Post: 22-07-2009, 01:02 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,710,828,797.12636 seconds with 16 queries