Summary of the invention
The embodiment of the invention provides a kind of flow media playing method and device, can overcome the buffer size that is fixedly installed in the existing streaming media playing process unreasonable and cause the relatively poor problem of result of broadcast, but the fluency of Effective Raise streaming media playing.
First aspect, the embodiment of the invention provide a kind of flow media playing method, comprising:
Detection obtains the downloading rate of Streaming Media;
According to the playback rate of described downloading rate and Streaming Media, adjust the size of the buffer area of stream medium data, wherein, the buffer area of described stream medium data is for being used for stream medium data is carried out the data space of caching.
In conjunction with first aspect, in the first possibility implementation, described playback rate according to described downloading rate and Streaming Media, the size of the buffer area of adjustment stream medium data specifically comprises:
Restart in the playing process in described Streaming Media initial play or after pausing, described downloading rate is during more than or equal to described playback rate, the size of the buffer area of stream medium data is adjusted to the first buffer storage length, in order to begin playing stream media after the buffer area of the stream medium data of described default minimal cache length is full, described the first buffer storage length is the length of the data cached buffer area that takies in the described current cache district and the maximum in the default minimal cache length.
In conjunction with the first possibility implementation of first aspect, in the second possibility implementation, described flow media playing method also comprises:
Restart in the playing process in described Streaming Media initial play or after pausing, described downloading rate is during less than playback rate, obtain buffer memory rate of change in the current cache district according to described downloading rate and playback rate, and adjust the size of the buffer area of described stream medium data according to described buffer memory rate of change;
Wherein, described buffer memory rate of change S (t)=D (t)-K (t), wherein, D (t) is the downloading rate of Streaming Media, the playback rate of K (t) Streaming Media, described buffer memory rate of change are used for the variable quantity that expression buffer area data increase or reduce.
In conjunction with the second possibility implementation of first aspect, described according to the buffer memory rate of change in the current cache district in the third possibility implementation, adjust the size of the buffer area of described stream medium data, specifically comprise:
When the buffer memory rate of change in current cache district increases, with the data cached buffer area that takies in the current cache district as the buffer area of stream medium data, so that the beginning playing stream media.
In conjunction with the second energy implementation of first aspect, described according to the buffer memory rate of change in the current cache district in the 4th kind of possibility implementation, adjust the size of the buffer area of described stream medium data, specifically comprise:
Do not change or reduce at the rate of change in current cache district, and the growth rate of described downloading rate reaches default when increasing threshold value, with the data cached buffer area that takies in the described current cache district as the buffer area of stream medium data, so that the beginning playing stream media.
In conjunction with the second energy implementation of first aspect, described according to the buffer memory rate of change in the current cache district in the 5th kind of possibility implementation, adjust the size of the buffer area of described stream medium data, specifically comprise:
Do not change or reduce at the rate of change in current cache district, and the growth rate of described downloading rate do not reach default and increase threshold value or when descending, according to the size of the data of buffer memory in the current cache district, adjust the size of the buffer area of described stream medium data.
In conjunction with the 5th kind of energy implementation of first aspect, the 6th kind may implementation in, described according to the size of the data of buffer memory in the current cache district, adjust the size of the buffer area of described stream medium data, specifically comprise:
The data B of buffer memory satisfies condition in the current cache district: B 〉=during G* (1-D/K), with the data cached buffer area that takies in the described current cache district as the buffer area of stream medium data, so that the beginning playing stream media;
Wherein, described G is the length of the Streaming Media do not play, and D is downloading rate, and K is playback rate.
In conjunction with the 6th kind of energy implementation of first aspect, in the 7th kind of possibility implementation, described flow media playing method also comprises:
The data B of current cache district buffer memory does not satisfy condition: B 〉=G* (1-D/K), and when G* (1-D/K) is not more than the maximum of buffer area of stream medium data, with described G*(1-D/K) length as the size of the buffer area of stream medium data, in order to after the buffer area of described stream medium data is full, begin playing stream media.
In conjunction with first aspect, in the 8th kind of possibility implementation, described flow media playing method also comprises:
After pausing, described Streaming Media restarts when playing, if pause number of times during greater than default pause threshold value, the size of the buffer area of increase stream medium data.
In conjunction with first aspect or first aspect first two or three four or five six or seven or eight kind may implementation, the 9th kind may implementation in, described detection obtains the downloading rate of Streaming Media, specifically comprises:
Starting the streaming media playing instruction, restarting the Preset Time of playing after beginning after perhaps pausing and detect the downloading rate that obtains Streaming Media;
Perhaps, starting the streaming media playing instruction, restart after perhaps pausing play beginning after, the periodic downloading rate that obtains Streaming Media that detects.
In conjunction with first aspect or first aspect first two or three four or five six or seven eight or nine kind may implementation, the tenth kind may implementation in, described flow media playing method also comprises:
The receiving stream media play instruction, and set the stream medium data memory space of default size as the buffer area of the initial stream medium data of playing stream media for streaming media playing.
In conjunction with first aspect first two or three four or five six or seven eight or nine or ten kind may implementation, the 11 kind may implementation in, described flow media playing method also comprises:
Restart in the playing process in described Streaming Media initial play or after pausing, if when waiting time surpasses the default stand-by period, with the data cached buffer area that takies in the current cache district as the buffer area of stream medium data, so that the beginning playing stream media.
In conjunction with first aspect, can implementation in the 12 in, described playback rate according to described downloading rate and Streaming Media is adjusted the size of the buffer area of stream medium data, specifically comprises:
In the streaming media playing process, according to the buffer memory rate of change in described downloading rate and the playback rate acquisition current cache district, and when described buffer memory rate of change increases, increase the size of the buffer area of stream medium data.
Second aspect, the embodiment of the invention provide a kind of streaming medium playing device, comprising:
Detection module is for detection of the downloading rate that obtains Streaming Media;
Adjusting module is used for the playback rate according to described downloading rate and Streaming Media, adjusts the size of the buffer area of stream medium data, and wherein, the buffer area of described stream medium data is for being used for stream medium data is carried out the data space of caching.
In conjunction with second aspect, in the first possibility implementation, described adjusting module, concrete being used for restarted playing process in described Streaming Media initial play or after pausing, described downloading rate is during more than or equal to described playback rate, the size of the buffer area of stream medium data is adjusted to the first buffer storage length, in order to begin playing stream media after the buffer area of the stream medium data of described default minimal cache length is full, described the first buffer storage length is the length of the data cached buffer area that takies in the described current cache district and the maximum in the default minimal cache length.
The first possibility implementation in conjunction with second aspect, in the second possibility implementation, described adjusting module, also be used for restarting playing process in described Streaming Media initial play or after pausing, described downloading rate is during less than playback rate, obtain buffer memory rate of change in the current cache district according to described downloading rate and playback rate, and adjust the size of the buffer area of described stream medium data according to described buffer memory rate of change;
Wherein, described buffer memory rate of change S (t)=D (t)-K (t), wherein, D (t) is the downloading rate of Streaming Media, the playback rate of K (t) Streaming Media, described buffer memory rate of change are used for the variable quantity that expression buffer area data increase or reduce.
The second possibility implementation in conjunction with second aspect, in the third possibility implementation, described adjusting module, when the concrete buffer memory rate of change that is used in the current cache district increases, with the data cached buffer area that takies in the current cache district as the buffer area of stream medium data so that the beginning playing stream media.
The second energy implementation in conjunction with second aspect, in the 4th kind of possibility implementation, described adjusting module, the concrete rate of change that is used in the current cache district does not change or reduces, and when the growth rate of described downloading rate reaches default growth threshold value, with the data cached buffer area that takies in the described current cache district as the buffer area of stream medium data so that the beginning playing stream media.
The second energy implementation in conjunction with second aspect, in the 5th kind of possibility implementation, described adjusting module, the concrete rate of change that is used in the current cache district does not change or reduces, and when the growth rate of described downloading rate does not reach default growth threshold value or decline, according to the size of the data of buffer memory in the current cache district, adjust the size of the buffer area of described stream medium data.
The 5th kind of energy implementation in conjunction with second aspect, in the 6th kind of possibility implementation, described adjusting module, the concrete data B that is used in current cache district buffer memory satisfies condition: B 〉=during G* (1-D/K), with the data cached buffer area that takies in the described current cache district as the buffer area of stream medium data so that the beginning playing stream media;
Wherein, described G is the length of the Streaming Media do not play, and D is downloading rate, and K is playback rate.
The 6th kind of energy implementation in conjunction with second aspect, in the 7th kind of possibility implementation, described adjusting module, the data B that also is used for current cache district buffer memory does not satisfy condition: B 〉=G* (1-D/K), and when G* (1-D/K) is not more than the maximum of buffer area of stream medium data, with described G*(1-D/K) length as the size of the buffer area of stream medium data, in order to after the buffer area of described stream medium data is full, begin playing stream media.
In conjunction with second aspect, the 8th kind may implementation in, described adjusting module also is used for restarting when playing after described Streaming Media pauses, if pause number of times during greater than default pause threshold value, the size of the buffer area of increase stream medium data.
In conjunction with second aspect or second aspect first two or three four or five six or seven or eight kind may implementation, in the 9th kind of possibility implementation, described detection module, specifically be used for starting the streaming media playing instruction, restart the Preset Time of playing after beginning after perhaps pausing and detect the downloading rate that obtains Streaming Media; Perhaps, be used for starting the streaming media playing instruction, restart after perhaps pausing play beginning after, the periodic downloading rate that obtains Streaming Media that detects.
In conjunction with second aspect or second aspect first two or three four or five six or seven eight or nine kind may implementation, the tenth kind may implementation in, described streaming medium playing device also comprises:
The play instruction receiver module is used for the receiving stream media play instruction, and sets default big or small stream medium data memory space as the buffer area of the initial stream medium data of playing stream media for streaming media playing.
In conjunction with second aspect first two or three four or five six or seven eight or nine or ten kind may implementation, in the 11 kind of possibility implementation, described adjusting module, also be used for restarting playing process in described Streaming Media initial play or after pausing, when if waiting time surpasses the default stand-by period, with the data cached buffer area that takies in the current cache district as the buffer area of stream medium data so that the beginning playing stream media.
In conjunction with second aspect, in can implementation in the 12, described adjusting module, also be used in the streaming media playing process, according to the buffer memory rate of change in described downloading rate and the playback rate acquisition current cache district, and when described buffer memory rate of change increases, increase the size of the buffer area of stream medium data.
To sum up, the present embodiment can be based on downloading rate and the playback rate of Streaming Media, dynamically adjust the size of the buffer area of stream medium data, can be according to current streaming media playing situation in the streaming media playing process, the buffer area of stream medium data is adjusted to suitable size, thus the relatively poor problem of streaming media playing fluency that can avoid only adopting in the existing streaming media playing fixing buffer size to cause.
Embodiment
The flow media playing method that the embodiment of the invention provides and device, can be based on downloading rate and the playback rate of Streaming Media, size to the buffer area of stream medium data is adjusted in real time, thereby can guarantee the fluency of streaming media playing, improves the experience that the user watches Streaming Media.
The schematic flow sheet of the flow media playing method that Fig. 1 provides for the embodiment of the invention one.The present embodiment is applied in the streaming media playing, particularly, the client of playing stream media is after receiving the streaming media playing instruction, get final product the receiving stream media data, and can adjust size for the buffer area of buffering data in stream media according to the downloading rate of Streaming Media and playback rate, improve the fluency of streaming media playing, particularly, as shown in Figure 1, the present embodiment method can comprise the steps:
Step 101, detection obtain the downloading rate of Streaming Media;
Step 102, according to the playback rate of downloading rate and Streaming Media, adjust the size of the buffer area of stream medium data, wherein, the buffer area of stream medium data is for being used for stream medium data is carried out the data space of caching.
In the present embodiment, when client needs playing stream media, but edge joint is received stream medium data, the broadcast of Streaming Media is carried out on the limit, and in the playing stream media process, can adjust based on the downloading rate of Streaming Media the size of the buffer area of stream medium data, realization is to the dynamic adjustment of the buffer size of stream medium data, in the time of can avoiding so existing employing single cache district size, because arranging, the size of buffer area unreasonablely cause the Streaming Media initial play stand-by period longer, perhaps play the rear waits for too long of pausing, perhaps cause the playback problem such as frequent pause because buffer setting is too small, but the fluency of Effective Raise streaming media playing improves the experience that the user watches Streaming Media.
When the playback rate that it will be understood by those skilled in the art that Streaming Media is carried in the streaming media playing instruction issuing, perhaps in the first paragraph stream medium data that receives, resolves and obtain.Above-mentioned detection obtains the downloading rate of Streaming Media, specifically can receive the streaming media playing instruction after, the periodic detection, and when detecting the downloading rate of Streaming Media each time, all adjust the size of the buffer area of stream medium data based on this downloading rate; Perhaps above-mentioned detection obtains the downloading rate of Streaming Media, also can be in each broadcast stage, for example restart after initial play, the pause and play or play continuously in the certain hour process, obtain according to the Preset Time detection, and obtain the downloading rate of Streaming Media in detection after, adjust the size of the buffer area of stream medium data based on the Streaming Media downloading rate.
To sum up, the flow media playing method that the present embodiment provides, can be based on downloading rate and the playback rate of Streaming Media, dynamically adjust the size of the buffer area of stream medium data, can be according to current streaming media playing situation in the streaming media playing process, the buffer area of stream medium data is adjusted to suitable size, thus the relatively poor problem of streaming media playing fluency that can avoid only adopting in the existing streaming media playing fixing buffer size to cause.
The schematic flow sheet of the flow media playing method that Fig. 2 provides for the embodiment of the invention two.The present embodiment can receive the streaming media playing instruction, in the Streaming Media initial play process, downloading rate and playback rate based on Streaming Media are dynamically adjusted the size of the buffer area of stream medium data, to avoid Streaming Media initial play waits for too long, particularly, client is after the streaming media playing instruction, just can adjust based on the present embodiment method the size of the buffer area of stream medium data, and after buffer area is full, start playing stream media, as shown in Figure 2, the present embodiment method can comprise the steps:
Step 201, receiving stream media play instruction;
Step 202, detection obtain the downloading rate of current Streaming Media;
Step 203, judge Streaming Media downloading rate whether more than or equal to the playback rate of Streaming Media, be execution in step 204 then, otherwise, execution in step 207;
Step 204, judge the data cached buffer area that takies in the current cache district size whether greater than default minimal cache length, be execution in step 205 then, otherwise, execution in step 206;
Step 205, with the size of the data cached buffer area that takies in the current cache district buffer area as stream medium data, execution in step 216;
Step 206, the buffer size of stream medium data is adjusted to default minimal cache length, so that after the buffer area of the stream medium data of default minimal cache length is full, execution in step 216;
Step 207, judging whether the buffer memory rate of change in current cache district increases, is execution in step 208 then, otherwise, execution in step 209;
Step 208, with the data cached buffer area that takies in the current cache district as the buffer area of stream medium data, execution in step 216;
Whether step 209, the growth rate of judging the downloading rate of Streaming Media reach the default threshold value that increases, and are execution in step 210 then, otherwise execution in step 211;
Step 210, with the data cached buffer area that takies in the current cache district as the buffer area of stream medium data, execution in step 216;
Step 211, judge in the current cache district whether the data B of buffer memory satisfies condition: B 〉=G* (1-D/K), be execution in step 212 then, otherwise execution in step 213;
Step 212, with the data cached buffer area that takies in the current cache district as the buffer area of stream medium data, execution in step 216;
Step 213, judging G* (1-D/K) whether greater than the maximum of the buffer area of stream medium data, is execution in step 214 then, otherwise, execution in step 215;
Step 214, with G*(1-D/K) length as the size of the buffer area of stream medium data so that after the buffer area of stream medium data is full, execution in step 216;
Step 215, with the maximum of the buffer area of the stream medium data buffer area as stream medium data so that after the buffer area of stream medium data is full, execution in step 216;
Step 216, beginning playing stream media.
In the above-mentioned steps 201, during the Streaming Media initial play, meeting receiving stream media play instruction, and based on streaming media playing instruction begins the receiving stream media data, and can after receiving the streaming media playing instruction be, set the stream medium data memory space of default size for streaming media playing, with the buffer area as the initial stream medium data of streaming media playing.Wherein, the size of the buffer area of the stream medium data that this is initial can be set according to the current network situation for client, perhaps by the client default setting.
In the present embodiment, in the above-mentioned steps 202, Streaming Media detects the downloading rate that obtains Streaming Media, specifically can be the Preset Time after the streaming media playing instruction, for example behind the 1s, downloading rate to Streaming Media detects, and obtaining the downloading rate of current Streaming Media, and adjusts the size of the buffer area of stream medium data based on downloading rate, perhaps, also can after receiving the streaming media playing instruction, periodically detect downloading rate, with the size of the buffer area of periodic adjustment stream medium data.
In the above-mentioned steps 203-step 205, when the downloading rate of Streaming Media during greater than playback rate, the enough Streaming Media smooth playing of current network resources are described, at this moment, the buffer size of stream medium data can be adjusted to a minimum value, stand-by period during with minimizing Streaming Media initial play, this minimum value namely is the first buffer storage length, is the length of the data cached buffer area that takies in the current cache district and the maximum of the minimum length of presetting.Wherein, be finished fast and a protection value causing streaming media playing to pause and set for fear of the buffer area data; this protection value can be avoided network bandwidth fluctuation and cause streaming media playing length; can be set as and to satisfy the size that Streaming Media can be play the buffer area of 0.5s-2s; namely in the data of the buffer area buffer memory of minimal cache length; can guarantee that Streaming Media can play 0.5s-2s; this minimal cache length can by the client default setting, perhaps also can be set according to the current network situation.
In above-mentioned steps 207 and the step 208, the downloading rate of Streaming Media is less than playback rate, and when the buffer memory rate of change in current cache district increases, the buffer memory that buffer area is described is continuing to increase, the rate of change of the downloading rate of Streaming Media is higher than playback rate, and this moment, the network bandwidth can satisfy the broadcast of Streaming Media, thereby can be with the data cached buffer area that takies in the current cache district as the buffer area of stream medium data, to carry out streaming media playing, can reduce the stand-by period of Streaming Media initial play.
In the above-mentioned steps 209-step 210, the downloading rate of Streaming Media is less than playback rate, the buffer memory rate of change in current cache district does not increase, and when the growth rate of the downloading rate of Streaming Media reaches default growth threshold value, illustrate that current transmission of flow media data is between the slow promoter region of TCP, network throughput can be along with the time rapid growth, and this moment, network can satisfy the Streaming Media smooth playing.
In above-mentioned steps 211 and the step 214, the downloading rate of Streaming Media is less than playback rate, the buffer memory rate of change in current cache district does not increase, and when the growth rate of the downloading rate of Streaming Media does not reach default growth threshold value, illustrate that the current network throughput is approaching or be tending towards stable state, and the network bandwidth is less than playback rate, at this moment, can whether satisfy the Streaming Media smooth playing according to data cached in the current cache district, determine the size of the buffer area of stream medium data.Wherein, if B 〉=G* (1-D/K), illustrate that then the data in the current cache district can satisfy the Streaming Media smooth playing, described G is the playout length of Streaming Media namely, when the data length of buffer area buffer memory satisfies this formula, the data that buffer memory is described can satisfy the Streaming Media smooth playing, can carry out streaming media playing this moment, to reduce the stand-by period of Streaming Media initial play, otherwise, the stream medium data that buffer memory in the buffer area is described can't satisfy smooth playing, this moment just can step 211 and step 213 adjust the size of buffer area.
In the step 213-step 215, by judging that G* (1-D/K) is whether greater than the maximum of the buffer area of stream medium data, determine the size of the buffer area of stream medium data, be about to a minimum value between maximum and the current minimum value that satisfies the Streaming Media smooth playing of the buffer area that is adjusted into stream medium data of buffer area of stream medium data, with the minimizing Streaming Media initial play stand-by period.
It will be appreciated by those skilled in the art that, during the Streaming Media initial play, when as long as the buffer area data of the stream medium data of setting are full, just can start broadcast, therefore, the size of the buffer area by adjusting stream medium data in the situation that guarantee the Streaming Media smooth playing, can reduce the initial play stand-by period.
For ease of embodiment of the invention technical scheme is had a better understanding, the below will be with in the Streaming Media initial play process, periodically detect the downloading rate of Streaming Media, and periodically the buffer size of stream medium data is adjusted into example based on downloading rate, technical solution of the present invention is described.Wherein, the size of buffer area is representing for the time of streaming media playing; The periodicity time of detecting the downloading rate of Streaming Media is set as tm, and namely each tm detects the downloading rate of a Streaming Media and the buffer area of stream medium data is once adjusted.
The schematic flow sheet of the flow media playing method that Fig. 3 provides for the embodiment of the invention three.As shown in Figure 3, the present embodiment method can comprise the steps:
Step 301, receiving stream media play instruction, and set the buffer area of the stream medium data of default size for streaming media playing, the initial value of setting reproduction time t is 0, and t is begun timing;
Step 302, judging whether current time t equals tm, is execution in step 303 then, otherwise, continue execution in step 302, until t=tm;
Step 303, detect and to obtain the downloading rate D of Streaming Media, and whether the downloading rate D that judges Streaming Media greater than the playback rate K of Streaming Media, is execution in step 304 then, otherwise, execution in step 308;
Step 304, the size of the buffer area of stream medium data is adjusted to Ts=max(t, E);
Step 305, whether judging current time t greater than Ts, is execution in step 306 then, otherwise, execution in step 307;
Step 306, playing stream media finish;
Step 307, judge whether current time t equals t '+tm, wherein t ' was for last time detecting the time of the downloading rate of Streaming Media, was execution in step 303 then, otherwise, continue execution in step 307, until t is t '+tm;
Step 308, judge whether the buffer memory rate of change S in the current cache district increases, i.e. S(t) whether greater than S(t-1), be execution in step 309 then, otherwise, execution in step 310;
Step 309, with the data cached buffer area that takies in the current cache district as the buffer area of stream medium data, execution in step 306;
Step 310, judging whether the growth rate of the downloading rate of current stream medium data is exponential increase, is execution in step 309 then, otherwise, execution in step 311;
Step 311, judge that current time t whether greater than default stand-by period Hs, is, then execution in step 309, otherwise, execution in step 312;
Step 312, judge in the current cache district whether the data B ' of buffer memory satisfies condition: B ' 〉=L* (1-D/K), be execution in step 309 then, otherwise, execution in step 313;
Step 313, the buffer area Ts of stream medium data is adjusted to Ts=min(Bmax, L) * (1-D/K), execution in step 305.
In the above-mentioned steps 301, client is after the streaming media playing instruction, the streaming media data cache district of default size just can be set for streaming media playing, simultaneously reproduction time t is carried out timing, and periodically detect the downloading rate of Streaming Media according to the tm cycle, and the buffer area of stream medium data is periodically adjusted.
In the above-mentioned steps 304, described Ts, E all refer to the time of streaming media playing, and wherein, Ts represents can be for the time span of streaming media playing when buffer area is full, E then is the time of presetting, and can supply the time span of the minimum of streaming media playing when buffer area is full when being used for the expression streaming media playing.This E is set as 0.5s-2s usually, and this E also can be described as the minimal time delay of guard time or initial play, be used for avoiding in network bandwidth fluctuation situation, but broadcasting speed during greater than speed of download, buffer memory is finished fast and causes playing the problem of pause.
In the above-mentioned steps 308, when the buffer memory rate of change S in the buffer area increases, illustrate that the downloading rate rate of change is higher than playback rate, the current network bandwidth can satisfy the smooth playing of Streaming Media, and just can start broadcast this moment.
In the above-mentioned steps 310, when the downloading rate of Streaming Media is exponential increase, also be the growth rate of downloading rate reach one default when increasing threshold value, just can determine that the current network bandwidth is between the slow promoter region of TCP, network throughput this moment index rapid growth in time, the smooth playing of Streaming Media can be satisfied, therefore, broadcast can be started.
In the above-mentioned steps 311, described stand-by period Hs is the maximum latency of default Streaming Media initial play, when surpassing waiting time Hs, user's the waits for too long of watching Streaming Media will cause the user to watch the experience extreme difference of Streaming Media, therefore, when surpassing this Hs, just can play-over, otherwise, just can based on the size of the stream medium data of buffer memory, adjust the size of the buffer area of stream medium data.
In the above-mentioned steps 312, B ' refers to that the data of buffer memory can be for the time span of streaming media playing in the buffer area of stream medium data, total be exactly the L Streaming Media playing duration, as B ' 〉=during L* (1-D/K), illustrate in the buffer area of stream medium data that the data of buffer memory can satisfy the smooth playing of Streaming Media, be to reduce the initial play stand-by period, just can directly utilize the data of buffer memory to play.
In the above-mentioned steps 313, Bmax is the maximum of the buffer area of stream medium data, also can be described as the buffer area that client can be the maximum that streaming media playing provides.
In the present embodiment, in the streaming media playing process, occur playing pausing and to restart when playing, can carry out the step identical with above-mentioned Fig. 2 or Fig. 3, adjust the buffer area of stream medium data, play the dead time to reduce, improve and restart the broadcast fluency.In addition, restarting when playing, also can according to the Streaming Media number of times that pauses, adjust the size of the buffer area of current stream medium data.The below will be with instantiation, and when playing restarting because pausing in the streaming media playing process, the adjustment process of the buffer area of stream medium data describes.
The schematic flow sheet of the flow media playing method that Fig. 4 provides for the embodiment of the invention four.As shown in Figure 4, the present embodiment method can comprise the steps:
In step 401, the streaming media playing process, play when pausing, the current time t1 that recording played is paused, and continue t1 is carried out timing;
Step 402, whether equaling t1+tm at current time t, is execution in step 403 then, otherwise, continue execution in step 402, until t=t1+tm;
Step 403, detect and to obtain the downloading rate D of Streaming Media, and whether the downloading rate D that judges Streaming Media greater than the playback rate K of Streaming Media, is execution in step 404 then, otherwise, execution in step 408;
Step 404, the size of the buffer area of stream medium data is adjusted to Tr=max(t-t1, E);
Step 405, whether judging current time t greater than t1+Tr, is execution in step 406 then, otherwise, execution in step 407;
Step 406, playing stream media finish;
Step 407, judge whether current time t equals t '+tm, wherein t ' was for last time detecting the time of the downloading rate of Streaming Media, was execution in step 403 then, otherwise, continue execution in step 407, until t is t '+tm;
Step 408, judge that whether the pause number of times of streaming media playing surpasses preset times n, increases the size in current cache district, execution in step 409 when the pause number of times surpasses preset times n;
Step 409, judge whether the buffer memory rate of change S in the current cache district increases, i.e. S(t) whether greater than S(t-1), be execution in step 410 then, otherwise, execution in step 411;
Step 410, with the data cached buffer area that takies in the current cache district as the buffer area of stream medium data, execution in step 406;
Step 411, judging whether the growth rate of the downloading rate of current stream medium data is exponential increase, is execution in step 410 then, otherwise, execution in step 412;
Step 412, judge that current time t whether greater than default stand-by period Hr, is, then execution in step 410, otherwise, execution in step 413;
Step 413, judge in the current cache district whether the data B ' of buffer memory satisfies condition:
B ' 〉=R* (1-D/K), be execution in step 410 then, otherwise, execution in step 414;
Step 414, the buffer area Tr of stream medium data is adjusted to Tr=min(Bmax, R) * (1-D/K), execution in step 405.
In the present embodiment, the buffer area when above-mentioned Tr is restarted broadcast for playing pause can allow the duration of streaming media playing when full; Above-mentioned R is the remaining time of streaming media playing; Above-mentioned Hr need to be restarted when playing for play pausing, restart play set restart the broadcast maximum delay, surpass this Hr if restart waiting time, illustrate that to play pause long, can affect user's viewing experience.
The present embodiment can be restarted when playing play pausing, can be based on Streaming Media speed of download and broadcasting speed, in real time the size of the buffer area of stream medium data is adjusted, and restart the stand-by period of broadcast to reduce Streaming Media.
In the above-mentioned steps 408, can be based on playing the pause number of times, and at the pause number of times during greater than default pause frequency n, illustrate to play and pause too much, can increase the size of the buffer area of stream medium data this moment, like this, can avoid streaming media playing pause number of times too much, affect fluency and user's viewing effect of streaming media playing.
Among each embodiment of the invention described above, in the streaming media playing process, can obtain buffer memory rate of change in the current cache district according to the downloading rate of Streaming Media and playback rate, and when the buffer memory rate of change increases, the size of the buffer area of increase stream medium data.It will be appreciated by those skilled in the art that, during the streaming media playing, streaming media server can continue to send flow data by network, and the transmission of flow data can be subjected to the restriction of TCP sliding window size, and the TCP sliding window is by min (RWD, CWD) determine, wherein RWD is receive window, and CWD is congestion window.In this case, by adjusting the size of buffer area, can avoid during the streaming media playing, try not to allow buffer storage length become the restriction of download bandwidth.
Particularly, in the practical application, watch for ensureing the smooth and easy of Streaming Media, when network availability bandwidth is more, should download as much as possible to store abundant content, during with the of short duration minimizing of convenient available bandwidth, cache contents is unlikely to be used up, cause playing and pause, therefore, when the present embodiment can increase at the rate of change of buffer memory, buffer size can be increased to S*R, wherein, R is Streaming Media residue reproduction time, until S*R equals Bmax.
One of ordinary skill in the art will appreciate that: all or part of step that realizes said method embodiment can be finished by the relevant hardware of program command, aforesaid program can be stored in the computer read/write memory medium, this program is carried out the step that comprises said method embodiment when carrying out; And aforesaid storage medium comprises: the various media that can be program code stored such as ROM, RAM, magnetic disc or CD.
The structural representation of the streaming medium playing device that Fig. 5 provides for the embodiment of the invention five.As shown in Figure 5, the present embodiment device can comprise detection module 11 and adjusting module 12, wherein:
Detection module 11 is for detection of the downloading rate that obtains Streaming Media;
Adjusting module 12 is used for the playback rate according to described downloading rate and Streaming Media, adjusts the size of the buffer area of stream medium data, and wherein, the buffer area of described stream medium data is for being used for stream medium data is carried out the data space of caching.
The present embodiment streaming medium playing device can realize broadcast to Streaming Media based on the invention described above embodiment method, and can dynamically adjust according to the Streaming Media downloading rate size of the buffer area of stream medium data, its specific implementation can be referring to the explanation of the invention described above embodiment of the method.
In the embodiment shown in fig. 5, above-mentioned adjusting module 12, restart in the playing process after specifically being used in described Streaming Media initial play or pause, described downloading rate is during more than or equal to described playback rate, the size of the buffer area of stream medium data is adjusted to the first buffer storage length, in order to begin playing stream media after the buffer area of the stream medium data of described default minimal cache length is full, described the first buffer storage length is the length of the data cached buffer area that takies in the described current cache district and the maximum in the default minimal cache length.
Further, above-mentioned adjusting module 12, restart in the playing process after also being used in described Streaming Media initial play or pause, described downloading rate is during less than playback rate, obtain buffer memory rate of change in the current cache district according to described downloading rate and playback rate, and adjust the size of the buffer area of described stream medium data according to described buffer memory rate of change; Wherein, described buffer memory rate of change S (t)=D (t)-K (t), wherein, D (t) is the downloading rate of Streaming Media, the playback rate of K (t) Streaming Media, described buffer memory rate of change are used for the variable quantity that expression buffer area data increase or reduce.
Further, above-mentioned adjusting module 12, when the buffer memory rate of change that specifically is used in the current cache district increases, with the data cached buffer area that takies in the current cache district as the buffer area of stream medium data, so that the beginning playing stream media.And the rate of change that is used in the current cache district does not change or reduces, and when the growth rate of described downloading rate reaches default growth threshold value, with the data cached buffer area that takies in the described current cache district as the buffer area of stream medium data so that the beginning playing stream media.
Further, above-mentioned adjusting module 12, the rate of change that specifically is used in the current cache district does not change or reduces, and when the growth rate of described downloading rate does not reach default growth threshold value or decline, according to the size of the data of buffer memory in the current cache district, adjust the size of the buffer area of described stream medium data.Particularly, adjusting module 12 is used in the current cache district, and the data B of buffer memory satisfies condition: B 〉=during G* (1-D/K), with the data cached buffer area that takies in the described current cache district as the buffer area of stream medium data so that the beginning playing stream media; Wherein, described G is the length of the Streaming Media do not play, and D is downloading rate, and K is playback rate.And adjusting module 12, the data B that also can be used for current cache district buffer memory does not satisfy condition: B 〉=G* (1-D/K), and when G* (1-D/K) is not more than the maximum of buffer area of stream medium data, with described G*(1-D/K) length as the size of the buffer area of stream medium data, in order to after the buffer area of described stream medium data is full, begin playing stream media.
Further, above-mentioned adjusting module 12 also is used in and restarts when playing after described Streaming Media pauses, if pause number of times during greater than default pause threshold value, the size of the buffer area of increase stream medium data.
Further, above-mentioned detection module 11 specifically is used in the instruction of startup streaming media playing, restarts the Preset Time of playing after beginning after perhaps pausing and detects the downloading rate that obtains Streaming Media; Perhaps, be used for starting the streaming media playing instruction, restart after perhaps pausing play beginning after, the periodic downloading rate that obtains Streaming Media that detects.
Further, above-mentioned adjusting module 12, restart in the playing process after also being used in described Streaming Media initial play or pause, when if waiting time surpasses the default stand-by period, with the data cached buffer area that takies in the current cache district as the buffer area of stream medium data so that the beginning playing stream media.
Further, above-mentioned adjusting module 12 also is used in the streaming media playing process, according to the buffer memory rate of change in described downloading rate and the playback rate acquisition current cache district, and when described buffer memory rate of change increases, increase the size of the buffer area of stream medium data.
The structural representation of the streaming medium playing device that Fig. 6 provides for the embodiment of the invention six.On above-mentioned technical scheme embodiment illustrated in fig. 5 basis, as shown in Figure 6, the present embodiment device also can comprise play instruction receiver module 13, be used for the receiving stream media play instruction, and set default big or small stream medium data memory space as the buffer area of the initial stream medium data of playing stream media for streaming media playing.
The structural representation of the streaming medium playing device that Fig. 7 provides for the embodiment of the invention seven.As shown in Figure 7, the present embodiment streaming medium playing device can comprise processor 10 and memory 20, and processor 10 can be connected with memory 20 by bus, and wherein, memory 20 can be used for storing instruction, and processor 10 is used for carrying out this instruction and is used for carrying out associative operation.Particularly, but the instruction of processor 10 execute stores 20 storages is for detection of the downloading rate that obtains Streaming Media, and for the playback rate according to described downloading rate and Streaming Media, adjust the size of the buffer area of stream medium data, wherein, the buffer area of described stream medium data is for being used for stream medium data is carried out the data space of caching.
In the present embodiment, processor 10 is restarted in the playing process after specifically being used in described Streaming Media initial play or pause, described downloading rate is during more than or equal to described playback rate, the size of the buffer area of stream medium data is adjusted to the first buffer storage length, in order to begin playing stream media after the buffer area of the stream medium data of described default minimal cache length is full, described the first buffer storage length is the length of the data cached buffer area that takies in the described current cache district and the maximum in the default minimal cache length.
Further, processor 10 is restarted in the playing process after also being used in described Streaming Media initial play or pause, described downloading rate is during less than playback rate, obtain buffer memory rate of change in the current cache district according to described downloading rate and playback rate, and adjust the size of the buffer area of described stream medium data according to described buffer memory rate of change; Wherein, described buffer memory rate of change S (t)=D (t)-K (t), wherein, D (t) is the downloading rate of Streaming Media, the playback rate of K (t) Streaming Media, described buffer memory rate of change are used for the variable quantity that expression buffer area data increase or reduce.
Further, when the buffer memory rate of change that processor 10 also is used in the current cache district increases, with the data cached buffer area that takies in the current cache district as the buffer area of stream medium data, so that the beginning playing stream media.
Further, the rate of change that processor 10 also is used in the current cache district does not change or reduces, and when the growth rate of described downloading rate reaches default growth threshold value, with the data cached buffer area that takies in the described current cache district as the buffer area of stream medium data so that the beginning playing stream media.
Further, the rate of change that processor 10 also is used in the current cache district does not change or reduces, and the growth rate of described downloading rate does not reach default and increases threshold value or when descending, and according to the size of the data of buffer memory in the current cache district, adjusts the size of the buffer area of described stream medium data.
Further, processor 10 also is used in the current cache district, and the data B of buffer memory satisfies condition: B 〉=during G* (1-D/K), with the data cached buffer area that takies in the described current cache district as the buffer area of stream medium data so that the beginning playing stream media; Wherein, described G is the length of the Streaming Media do not play, and D is downloading rate, and K is playback rate.
Further, the data B that processor 10 also can be used for current cache district buffer memory does not satisfy condition: B 〉=G* (1-D/K), and when G* (1-D/K) is not more than the maximum of buffer area of stream medium data, with described G*(1-D/K) length as the size of the buffer area of stream medium data, in order to after the buffer area of described stream medium data is full, begin playing stream media.
In the present embodiment, processor 10 also is used in restarts when playing after described Streaming Media pauses, if pause number of times during greater than default pause threshold value, the size of the buffer area of increase stream medium data.
In the present embodiment, processor 10 also is used in and starts the streaming media playing instruction, restarts the Preset Time of playing after beginning after perhaps pausing and detects the downloading rate that obtains Streaming Media; Perhaps, starting the streaming media playing instruction, restart after perhaps pausing play beginning after, the periodic downloading rate that obtains Streaming Media that detects.
In the present embodiment, processor 10 also can be used for the receiving stream media play instruction, and sets the stream medium data memory space of default size as the buffer area of the initial stream medium data of playing stream media for streaming media playing.
In the present embodiment, processor 10 is restarted in the playing process after also being used in described Streaming Media initial play or pause, when if waiting time surpasses the default stand-by period, with the data cached buffer area that takies in the current cache district as the buffer area of stream medium data so that the beginning playing stream media.
In the present embodiment, processor 10 also is used in the streaming media playing process, according to the buffer memory rate of change in described downloading rate and the playback rate acquisition current cache district, and when described buffer memory rate of change increases, increases the size of the buffer area of stream medium data.
It should be noted that at last: above each embodiment is not intended to limit only in order to technical scheme of the present invention to be described; Although with reference to aforementioned each embodiment the present invention is had been described in detail, those of ordinary skill in the art is to be understood that: it still can be made amendment to the technical scheme that aforementioned each embodiment puts down in writing, and perhaps some or all of technical characterictic wherein is equal to replacement; And these modifications or replacement do not make the essence of appropriate technical solution break away from the scope of various embodiments of the present invention technical scheme.