全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:4124
推到 Plurk!
推到 Facebook!

如何编写流播放器?

尚未結案
mysql
一般會員


發表:7
回覆:15
積分:4
註冊:2003-12-10

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-03-30 13:08:33 IP:61.234.xxx.xxx 未訂閱
我最近想写一个流播放器。 流播放(streaming)一般使用的方式是:cient连接到server以后,从server上读取文件,存储到client的buffer中,然后由播放器播放。 流传输的过程可以使用indy中的tidtcpserver/client来写,但播放器我就不知道如何做? 看过realone的SDK,都是VC的,好像可以通过编写插件来实现(编写插件读取自己流服务器的内容)。看起来非常复杂。 我知道使用DSPACK编写播放器非常方便,但如果用来做流播放器,该如何写? 虚心请教各位大哥,给小弟指明一条名路。
mysql
一般會員


發表:7
回覆:15
積分:4
註冊:2003-12-10

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-03-30 20:49:55 IP:61.234.xxx.xxx 未訂閱
我已经找到一些相关的主题: http://delphi.ktop.com.tw/topic.php?topic_id=19430 http://delphi.ktop.com.tw/topic.php?topic_id=34286 http://delphi.ktop.com.tw/topic.php?topic_id=29260 http://delphi.ktop.com.tw/topic.php?topic_id=19558 http://delphi.ktop.com.tw/topic.php?topic_id=43399 我现在设想的关键是: 没有必要选用RTSP等传输协议,只需要把影片内容下载到缓冲区,然后播放缓冲区的内容。 如果需要快进、暂停、拖动等功能,就需要分析使用者发出的命令,重新更新缓冲区。 另外,我看见过有人使用REALONE插件的方式。但由于real提供的SDK都是VC的,我不是很熟悉。不知道那位大哥能指点一下?
conundrum
尊榮會員


發表:893
回覆:1272
積分:643
註冊:2004-01-06

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-03-30 21:12:12 IP:61.64.xxx.xxx 未訂閱
改變一下想法 找這位 japhenchen 善心人士的問答 資料看看就知 http://delphi.ktop.com.tw/pop_profile.asp?mode=display&id=13135 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=39811
japhenchen
高階會員


發表:51
回覆:444
積分:184
註冊:2003-07-23

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-03-31 12:33:12 IP:211.96.xxx.xxx 未訂閱
其實如果用過了dspack,會知道作者其實已經把這個流媒体播放器給解決掉了~ 安裝完dspack進delphi之後,在\program files\dspack\demos\d6-d7\asf\asf capture就是一個server的demo,編譯完之後就可以直接使用(demo是抓webcam),執行這支demo,然後區域網路上的隨便一台電腦,用WindowsMediaPlayer7以上版本,在選單上打開檔案->打開URL,輸入mms://10.10.10.10(這Server的ip),就可以看到你要的東西了!這支demo里設定最大客戶端數量是8台,你可以依需要改大一點,我測試到60台都沒問題,外網只要沒有防火牆阻擋,也是橫行無阻,聲音也一塊傳送哦!比起那堆死要錢的REAL STREAM SERVER好多了~~~~DSPACK跟里面的DEMO都是完全免費 藏私の禁止
japhenchen
高階會員


發表:51
回覆:444
積分:184
註冊:2003-07-23

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-03-31 12:37:59 IP:211.96.xxx.xxx 未訂閱
修改一下.... 是 mms://10.10.10.10:3333 (他開的是3333port) ... 如果不喜歡這端口,或者想改到wmp的預設1755或80口,都可以~~~~隨你哦,別沖到其他的service的就好.... 98/XP/2000/NT都可以使用,只要有裝directx的電腦就行 藏私の禁止
mysql
一般會員


發表:7
回覆:15
積分:4
註冊:2003-12-10

發送簡訊給我
#6 引用回覆 回覆 發表時間:2004-03-31 13:36:15 IP:61.234.xxx.xxx 未訂閱
我測試過它的ASF和MMS播放功能。 但就是因為我想播放RM格式的。dspack增加filter以后可以播放RM檔案,但通過網路播放就有問題。 所以,我的想法是:不管是什么檔案,隻要dspack能夠播放的,就從緩衝區中播放就可以暸。而緩衝區由我另外的程式生成。 不知道我的想法是否可以做得到?請japhenchen 大哥多多指教! 謝謝! 發表人 - mysql 於 2004/03/31 13:37:07
mysql
一般會員


發表:7
回覆:15
積分:4
註冊:2003-12-10

發送簡訊給我
#7 引用回覆 回覆 發表時間:2004-04-01 03:55:09 IP:211.156.xxx.xxx 未訂閱
很高兴又找到了一点东西: http://codecentral.borland.com/codecentral/ccweb.exe/listing?id=21110 它的说明是: A direct show source filter reading a media stream directly (not from a file). Based on DSPack .... (源代码下载:http://delphi.ktop.com.tw/topic.php?TOPIC_ID=47454) 其中,他把PLAYWIN的程序做了一些修改: procedure TFormPlayWin.OpenMenuClick(Sender: TObject); begin if OpenDialog.Execute then begin if not FilterGraph.Active then FilterGraph.Active := true; FilterGraph.ClearGraph; TestCustomStream(TFileStream.Create(OpenDialog.FileName,fmOpenRead or fmShareDenyWrite), MitCompressed.Checked); exit; FilterGraph.RenderFile(OpenDialog.FileName); VideoWindow.PopupMenu := PopupMenu; SoundLevel.Position := FilterGraph.Volume; FilterGraph.Play; end; end; procedure TFormPlayWin.TestCustomStream(Src: TStream; Compress: boolean); var Z : TStream; D : TStream; TS : TCustomSrcFilter; Size: Int64; begin Size := Src.Size; //Size := 0; if Compress then begin Z := TMemoryStream.Create; D := TCompressionStream.Create(clDefault, Z); D.CopyFrom(Src, 0); D.Free; D := TDecompressionStream.Create(Z); D.Position := 0; Src.Free; end else D := Src; TS := TCustomSrcFilter.Create(D, Compress, Size); RenderFilter(TS); end; 它里面使用到一个自定义的FILTER,README.TXT如下说: I wanted for a long time a way to play a media stream directly (not from a file). Here it is. It was quite challenging, but in the end you have a way to render a media stream without saving to a file; for example play a sound (any kind) or avi file directly from a resource stream. It fully supports compressed streams! The demo is compressing a file into a ZLib stream and playing it. The component is a filter with an output pin that should be rendered. It takes care of most common formats, but it may not be all; send a feedback when something is not working. It is based on DSPack; the declaration looks like this: type TCustomSrcFilter = class(TBCBaseFilter) protected public constructor Create(AStream : TStream; FwdOnly: boolean = false; const StreamSize: Int64 = 0); overload; constructor Create(AStream : IStream; FwdOnly: boolean = false; const StreamSize: Int64 = 0); overload; destructor Destroy; override; function GetPin(n: Integer): TBCBasePin; override; function GetPinCount: Integer; override; property OutPin : IPin read GetOutPin; function NonDelegatingRelease: Integer; override; stdcall; end; Internally it is using IStream interface, so the TStream is used via a StreamAdapter. FwdOnly is a flag that instructs the filter to treat the stream as forward only; it means all seek operations on a previous position will first perform a seek to the start then set the position. This is especially for ZLib implementation of streams, so there is no workaround needed to use a compressed stream! Some filters (avi parser) require the length of the stream (uncompressed). As implemented in ZLib, one can obtain the size only by setting successive positions and actually decompressing the stream; when the end is reached an error is raised. It will not break the code, but you might be misleaded when running from the debugger. It's better to use some kind of the wrapper and return a stored size when the stream is seek at the end. New: I already modified the component so you can pass the size of the stream in the constructor. If you don't know it, of course leave it to default and it will be determined as described. It is also possible to pass an approximation of the stream size; usually it's better to pass a bigger size. This value is used by the parser filter and I can't say exactly how it is used. One can simply build a dll with a generic direct show filter to use in other environments by registering and/or declaring some functions that create the filter. 但由于下载的程序中没有FILTER,所以还不知道它具体如何实现。 另外,如果需要改成网络播放的话,好像还有一点困难:如何把一个文件分拆开一个一个的包(package),一段一段的播放呢? 發表人 - mysql 於 2004/04/01 13:44:37
debussy
一般會員


發表:0
回覆:1
積分:0
註冊:2005-04-19

發送簡訊給我
#8 引用回覆 回覆 發表時間:2005-06-15 11:46:44 IP:218.88.xxx.xxx 未訂閱
There is a delay in asfcapture demo,about 7-10s,how to do a stream without delay in lan?thanks
killghost
一般會員


發表:14
回覆:21
積分:7
註冊:2004-04-21

發送簡訊給我
#9 引用回覆 回覆 發表時間:2005-07-07 11:35:45 IP:218.88.xxx.xxx 未訂閱
这个问题在使用TMediaPlayer控件的时候同样存在,MSDN的资料中说,可以设置TMediaPlayer的BufferTime来解决,可以设置以后并没有什么改变。难道10秒时默认设置吗?
killghost
一般會員


發表:14
回覆:21
積分:7
註冊:2004-04-21

發送簡訊給我
#10 引用回覆 回覆 發表時間:2005-07-14 14:11:43 IP:218.88.xxx.xxx 未訂閱
能否实现连续播放多个流文件?这样就可以实现实时下载网上的资源并立刻播放出来。
系統時間:2024-04-26 8:26:18
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!