在Rtmp Flash Player中我有一个问题,使用我的Rtmp网址播放了视频,但是当我点击暂停时,视频就不见了。
答案 0 :(得分:0)
步骤:1复制代码并将以下代码粘贴到fla
中function writeln(msg){
trace_txt.text += msg + "\n";
trace_txt.scroll = trace_txt.maxscroll;
}
/**
* onStatus toggles the Connect button depending on the
* current connection state, does some clean up when the
* connection is closed, and sets up the NetStream.
*/
NetConnection.prototype.onStatus = function(info){
writeln("NetConnection.onStatus> " + info.code);
if (this.isConnected){
connection_btn.setLabel("Disconnect");
}
else{
connection_btn.setLabel("Connect");
if (in_ns){
in_ns.close();
in_ns = null;
}
}
if (info.code == "NetConnection.Connect.Success"){
in_ns = new NetStream(nc);
in_ns.setBufferTime(2)
videoViewer.attachVideo(in_ns);
in_ns.play("sample");
stopStart_btn.setLabel("Stop");
}
}
/** Reports connection events in the text field. */
NetStream.prototype.onStatus = function(info){
writeln("NetStream.onStatus> " + info.code);
}
/**
* Connect or disconnect depending on the label of the
* Connect button.
*/
function doConnect(btn){
if (btn.getLabel() == "Connect"){
if (nc) nc.close();
nc = new NetConnection();
if (nc.connect("rtmp://192.168.0.173/vod")){
btn.setLabel("Wait...");
}
else{
writeln("Bad URI: " + nc.uri);
}
}
else if (btn.getLabel() == "Disconnect"){
nc.close();
}
}
/**
* Start or stop the stream from playing based on the
* label of the stopStart_btn.
*/
function doStopStart(btn){
if (btn.getLabel() == "Stop"){
if (in_ns) {
in_ns.play(false);
btn.setLabel("Play");
}
}
else {
if (in_ns){
in_ns.play("sample");
btn.setLabel("Stop");
}
}
}
/** Pause or unpause the stream. Called by the pause_btn */
function doPause(btn){
if(in_ns) in_ns.pause();
}
function onChangeTime(cb){
if(in_ns) in_ns.seek(parseFloat(cb.getValue()))
}
this.onEnterFrame = function(){
if (in_ns) {
streamTime_txt.text = in_ns.time;
streamBuffer_txt.text = in_ns.bufferLength;
}
}