×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    188

    buffering mp3 using http for streaming

    hi..

    i am new to Symbian. i have to stream mp3 using http (http://my-server.com/songs/song1.mp3). i read some thread, it says, CMdaAudioOutputStream API can be used.

    First i have buffer mp3 data. then i have to use CMdaAudioOutputStream to play this buffer.

    my question is,

    1. how to buffer mp3 data using http? sample example or API?
    2.how to use CMdaAudioOutputStream API to play this buffer? sample example?

    please help me.

    thanks in advance

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,694

    Re: buffering mp3 using http for streaming

    Quote Originally Posted by kuddy_abc View Post
    1. how to buffer mp3 data using http? sample example or API?
    Any HTTP example should do the job, even the SDK-s have some (Examples\AppProts\exampleclient and S60Ex\WebClient).
    2.how to use CMdaAudioOutputStream API to play this buffer? sample example?
    You said you found some related threads, like this one: http://discussion.forum.nokia.com/fo...ad.php?t=84568

  3. #3
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    188

    Re: buffering mp3 using http for streaming

    thank you for your reply.

    using webclient example i could receive text file, html file. How to buffer mp3? Please excuse me if i asked stupid question. i am new to Symbian and networking.

    thanks in advance

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,694

    Re: buffering mp3 using http for streaming

    Note that the HTTP API-s do not know that you receive text file or anything else, they are just files. So you can download .mp3 files in the very same way, just instead of displaying them, you could save them on the memory card for example, and play it with CMdaAudioPlayerUtility after that.

  5. #5
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    188

    Re: buffering mp3 using http for streaming

    hi.. wizard_hu

    thank u for your replay.

    using WebClient, when i buffer mp3 OR large file, after buffering some bytes, application is automatically closed.

    why?

    thanks

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,694

    Re: buffering mp3 using http for streaming

    You are probably running out of memory, but you can check the actual error message: http://wiki.forum.nokia.com/index.ph...ded_panic_code (and http://wiki.forum.nokia.com/index.php/Error_codes when necessary).
    Unless you set something else in the .mmp file (EPOCHEAPSIZE keyword, but you can find the setting in the mmp editor of Carbide.c++), you have 1 megabyte by default. Generally it would be safer to save the data as you are getting it.

  7. #7
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    188

    Re: buffering mp3 using http for streaming

    hi.. wizard_hu

    thank very much for your replay. your reply was very helpful for me even i am new to Symbian.

    now
    i can stream mp3 from local file.(C:\\song.mp3)
    i can buffer mp3 over http. ///////TPtrC8 dataChunk;

    now i want to stream mp3 over http. so i ant to send the data received by http (TPtrC8 dataChunk) to (TRAP(err, iAudioStream->WriteL(iBuffer))). please modify the blow code to do this.

    thank again.



    HTML Code:
    case THTTPEvent::EGotResponseBodyData:
          {
          // Part (or all) of response's body data received. Use
          // aTransaction.Response().Body()->GetNextDataPart() to get the actual
          // body data.
    
          // Get the body data supplier
          MHTTPDataSupplier* body = aTransaction.Response().Body();
          TPtrC8 dataChunk;
    
          // GetNextDataPart() returns ETrue, if the received part is the last
          // one.
          TBool isLast = body->GetNextDataPart(dataChunk);
          //iObserver.ClientBodyReceived(dataChunk);
    
          //HBufC* resBytesReceived = StringLoader::LoadLC(R_HTTP_BYTES_RECEIVED, dataChunk.Length());
          //iObserver.ClientEvent(*resBytesReceived);
          //CleanupStack::PopAndDestroy(resBytesReceived);
    
          // NOTE: isLast may not be ETrue even if last data part received.
          // (e.g. multipart response without content length field)
          // Use EResponseComplete to reliably determine when body is completely
          // received.
          if (isLast)
            {
            HBufC* resBodyReceived = StringLoader::LoadLC(R_HTTP_BODY_RECEIVED);
            iObserver.ClientEvent(*resBodyReceived);
            CleanupStack::PopAndDestroy(resBodyReceived);
            }
    
          // Always remember to release the body data.
          body->ReleaseData();
          break;
          }
    HTML Code:
    ////////////////RFile iFile;
    ////////////////RBuf8 iBuffer;
    
    void CAudioStreamPlayer::PlayL(RFs& aFs, const TDesC& aFileName)
    	{
    	Stop();
    	
    	// Open the file for reading.
    	iFile.Close();
    	User::LeaveIfError(iFile.Open(aFs, aFileName, EFileRead));
    	
    	// Open the audio device for streaming.
    	iAudioStream->Open(NULL);
    	}
    void CAudioStreamPlayer::MaoscOpenComplete(TInt aError)
    	{
    	if (KErrNone == aError)
    		{
    		// Read the buffer.
    		iFile.Read(iBuffer, KMaxBuffer);
    		
    		// Set the data type.
    		TInt err = KErrNone;
    		TRAP(err, iAudioStream->SetDataTypeL(KMMFFourCCCodeMP3));
    		
    		if (KErrNone == err)
    			{
    			// Set the sampling rate and number of channels.
    			TRAP(err, iAudioStream->SetAudioPropertiesL(
    					TMdaAudioDataSettings::ESampleRate44100Hz,
    					TMdaAudioDataSettings::EChannelsStereo));
    	
    			if (KErrNone == err)
    				{
    				// Set volume and play it.
    				iAudioStream->SetVolume(
    						iAudioStream->MaxVolume() / KVolumeDenominator);
    				TRAP(err, iAudioStream->WriteL(iBuffer));
    				}
    			}
    		
    		if (KErrNone != err)
    			{
    			DisplayErrorMessage(err);
    			}
    		}
    	else
    		{
    		// Do something when error happens.
    		DisplayErrorMessage(aError);
    		}
    	}
    
    void CAudioStreamPlayer::MaoscBufferCopied(TInt aError,
    		const TDesC8& /*aBuffer*/)
    	{
    	if (KErrNone == aError)
    		{
    		// Read the next buffer.
    		iFile.Read(iBuffer, KMaxBuffer);
    		TRAPD(err, iAudioStream->WriteL(iBuffer));
    		
    		if (KErrNone != err)
    			{
    			DisplayErrorMessage(err);
    			}
    		}
    	else
    		{
    		// Do something when error happens.	
    		}
    	}
    
    void CAudioStreamPlayer::MaoscPlayComplete(TInt /*aError*/)
    	{
    	iFile.Close();
    	}

Similar Threads

  1. Http Buffering
    By uozzon in forum Mobile Java Networking & Messaging & Security
    Replies: 4
    Last Post: 2010-08-03, 07:47
  2. streaming mp3 audio using http
    By kuddy_abc in forum Streaming and Video
    Replies: 1
    Last Post: 2010-05-30, 21:35
  3. CMdaAudioPlayerUtility OpenUrl - http mp3
    By dgaur in forum Symbian Media (Closed)
    Replies: 1
    Last Post: 2010-03-26, 10:10
  4. How can I call http session simultaneously?
    By gusta72 in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2006-10-19, 19:58
  5. WAP Buffering / Sockets / Http / GPRS
    By Ian Johnson in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2003-04-11, 13:54

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×