diff --git a/mbtk/mbtk_audio_lib/src/mbtk_wav.c b/mbtk/mbtk_audio_lib/src/mbtk_wav.c
index dca245c..cfe08a8 100755
--- a/mbtk/mbtk_audio_lib/src/mbtk_wav.c
+++ b/mbtk/mbtk_audio_lib/src/mbtk_wav.c
@@ -9,6 +9,11 @@
 
 #define WAV_PLAY_BUFF 2048
 
+typedef struct {
+    const unsigned char *pcm_data;
+    int data_size;
+} audio_buff_t;
+
 static int wav_play_fd = -1;
 static audio_play_state_enum play_state = AUDIO_PLAY_STATE_STOP;
 static pthread_cond_t play_cond;
@@ -19,6 +24,8 @@
 static struct wav_header recorder_header;
 static uint32 recorver_data_count = 0;
 
+static audio_buff_t audio_buff;
+
 static void audio_play_thread(void *arg)
 {
     int rc, len, frames = 0;
@@ -28,6 +35,7 @@
     pthread_mutex_init(&play_mutex, NULL);
     pthread_cond_init(&play_cond, NULL);
 
+    int data_send = 0;
     while (TRUE) {
         /* Playback loop */
         pthread_mutex_lock(&play_mutex);
@@ -44,16 +52,32 @@
         }
 
         memset(buf, 0x00, sizeof(buf));
-        len = read(wav_play_fd, buf, WAV_PLAY_BUFF);
-        if (len == -1) {
-            LOGE("%s: error reading from file", __FUNCTION__);
-            goto thread_end;
-        }
+        if(wav_play_fd > 0) { // Play file.
+            len = read(wav_play_fd, buf, WAV_PLAY_BUFF);
+            if (len == -1) {
+                LOGE("%s: error reading from file", __FUNCTION__);
+                goto thread_end;
+            }
 
-        if (len == 0) {
-            /* reached EOF */
-            LOGE("%s: Read wav file end.", __FUNCTION__);
-            break;
+            if (len == 0) {
+                /* reached EOF */
+                LOGE("%s: Read wav file end.", __FUNCTION__);
+                break;
+            }
+        } else { // Play buffer.
+            if(data_send >= audio_buff.data_size) {
+                /* reached EOF */
+                LOGE("%s: Read buffer end.", __FUNCTION__);
+                break;
+            }
+            if(audio_buff.data_size - data_send >= WAV_PLAY_BUFF) {
+                memcpy(buf, audio_buff.pcm_data + data_send, WAV_PLAY_BUFF);
+                len = WAV_PLAY_BUFF;
+            } else {
+                memcpy(buf, audio_buff.pcm_data + data_send, audio_buff.data_size - data_send);
+                len = audio_buff.data_size - data_send;
+            }
+            data_send += len;
         }
 
         if((rc = mbtk_audio_pcm_play_data_send(buf, len)) < len) {
@@ -71,8 +95,10 @@
     pthread_cond_destroy(&play_cond);
     mbtk_audio_pcm_play_stop();
 
-    if (close(wav_play_fd))
-        LOGE("%s: error closing file", __FUNCTION__);
+    if(wav_play_fd > 0) {
+        if (close(wav_play_fd))
+            LOGE("%s: error closing file", __FUNCTION__);
+    }
 
     wav_play_fd = -1;
     LOGD("%s: finished pcm playback.", __FUNCTION__);
@@ -204,6 +230,56 @@
     return 0;
 }
 
+int mbtk_audio_wav_stream_play_start(const unsigned char *pcm_data, int data_size, int sample_rate, int num_channels)
+{
+    if(play_state != AUDIO_PLAY_STATE_STOP) {
+        LOGW("Audio is playing...");
+        return -1;
+    }
+
+    //Support 8k/16k & mono wave file
+    if (((sample_rate != 8000) && (sample_rate != 16000))
+            || (num_channels != 1) ) {
+        LOGD("%s: error wave file:sample_rate = %d, num_channels = %d!!",
+                __FUNCTION__,sample_rate, num_channels);
+        return -1;
+    }
+
+    LOGE("%s: success open wave stream, sample_rate = %d, num_channels = %d.",
+            __FUNCTION__,  sample_rate, num_channels);
+
+    if ((8000 == sample_rate) && (1 == num_channels)) {
+        mbtk_audio_pcm_sample_rate_set(MBTK_AUDIO_SAMPLE_RATE_8000);
+    } else if ((16000 == sample_rate) && (1 == num_channels)) {
+        mbtk_audio_pcm_sample_rate_set(MBTK_AUDIO_SAMPLE_RATE_16000);
+    }
+
+    if (mbtk_audio_pcm_play_start()) {
+        LOGE("%s: error opening output device.", __FUNCTION__);
+        return -1;
+    }
+
+    audio_buff.pcm_data = pcm_data;
+    audio_buff.data_size = data_size;
+    LOGD("Start play wav stream...");
+
+    pthread_attr_t thread_attr;
+    pthread_attr_init(&thread_attr);
+    if(pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED))
+    {
+        LOGE("pthread_attr_setdetachstate() fail.");
+        return -1;
+    }
+
+    if (pthread_create(&play_thread_play, NULL, (void *)&audio_play_thread, NULL) < 0) {
+        LOGE("%s: error creating thread_play!", __FUNCTION__);
+        return -1;
+    }
+
+    return 0;
+}
+
+
 int mbtk_audio_wav_play_pause()
 {
     int result = 0;
@@ -211,7 +287,7 @@
     if(play_state == AUDIO_PLAY_STATE_RUNNING) {
         play_state = AUDIO_PLAY_STATE_PAUSE;
     } else {
-        result = -1;
+        // result = -1;
         LOGW("Audio state : %d", play_state);
     }
     pthread_mutex_unlock(&play_mutex);
@@ -226,7 +302,7 @@
         play_state = AUDIO_PLAY_STATE_RUNNING;
         pthread_cond_signal(&play_cond);
     } else {
-        result = -1;
+        // result = -1;
         LOGW("Audio state : %d", play_state);
     }
     pthread_mutex_unlock(&play_mutex);
@@ -253,7 +329,7 @@
         LOGD("Play thread exit success.");
     } else {
         pthread_mutex_unlock(&play_mutex);
-        result = -1;
+        // result = -1;
         LOGW("Audio state : %d", play_state);
     }
 
