Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 28th, 2013, 09:59 AM
Registered User
Join Date: Sep 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Lightbulb How to play back media in a softphone


I am working on a project to develop a softphone and I need to play back media in my softphone. I am using this sample program provided by Ozeki VoIP SIP SDK: http://www.voip-sip-sdk.com/p_406-vo...ling-voip.html
So here is my project:

Playing an uncompressed .wav audio file, I needed to find and open one. Ozeki VoIP SIP SDK provided me a useful tool WaveStreamPlayback that is for audio playing in case of .wav files.

The WaveStreamPlayback is a MediaHandler that can be initialized by setting the audio file to be played. I could do this by adding the filename (if it is in the same directory as the program) or the file path. I could also specify the repetition, the packetization time and if it is necessary I could set that a cache stream needs to be used.

In the sample program the audio file to play is specified by a textbox element. In this textbox I could give the file path or filename to be played. I could also use the Open button to pop up a browsing window where I could browse for the proper audio file.

When the audio file is specified, I could start playing with pressing the Start button on the GUI. If every parameter is set properly the playback will start buttonStartPlayback.Text = "Pause";

1.	    WaveStreamPlayback.StartStreaming();  
2.	    WaveStreamPlayback.IsStreaming = true;  
3.	}
The Start button is also used for pausing a started stream. The difference between pausing and stopping a stream is that in the case of pausing, I could restart the streaming from the exact point it has been paused. In case of stopping the restart will be started from the beginning of the file.

1.	buttonStartPlayback.Text = "Start";  
2.	WaveStreamPlayback.PauseStreaming();  
3.	WaveStreamPlayback.IsStreaming = false;
If I wanted to stop the audio streaming, I needed to press the stop button and the following code will run

1.	textBoxRecordingFile.Text = string.Empty;  
2.	if (WaveStreamPlayback != null)  
3.	{  
4.	        WaveStreamPlayback.StopStreaming();  
5.	        buttonStartPlayback.Text = "Start";  
6.	        speaker.Stop();  
7.	        connector.Disconnect(WaveStreamPlayback, speaker);  
8.	        WaveStreamPlayback.Dispose();  
9.	        WaveStreamPlayback = null;  
10.	}
The audio stream playing could also be used for playing an audio file into a call. In this case I needed to connect the WaveStreamPlayback object to the PhoneCallAudioSender object with the connector. In that case the StartStreaming() method will play the audio file directly into the established call.
You can find more useful information about other VoIP technologies on the website.

Good developing!

Similar Threads
Thread Thread Starter Forum Replies Last Post
Softphone building BlaneB C# 1 May 14th, 2014 04:12 AM
play multiple song using embeded media player kumiko Javascript 0 September 10th, 2008 11:10 AM
Media Play Apocolypse2005 Pro VB 6 7 August 9th, 2007 04:05 PM
Help. How to play media files using DirectX dextergaisie Pro VB 6 0 May 15th, 2007 06:09 AM
Link Play Window Media in GridView johnpie99 ASP.NET 2.0 Professional 0 April 12th, 2007 12:01 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.