Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ouzhou committed Jul 19, 2019
1 parent f978c49 commit 82bd61d
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 14 deletions.
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ rtmp 流直播定制 flash 播放器
// 因为加载 swf 是异步操作,需要等待swf加载完成后才能进行调用
// 但是因为 swf 文件的 onload 并不会调用
// 解决办法有两种
// 1 在 swf 里面调用一个 js 方法通知(考虑到在react组件中使用,暂无实现)
// 1 在 swf 里面调用一个 js 方法通知(考虑到在react组件中使用,暂无实现)
// 2 用定时器判断加载状态
const app = document.getElementById("app");
let timer = null;
Expand Down Expand Up @@ -95,3 +95,32 @@ app.stopLive();
// 暂停直播,因为是直播流,暂停后不提供续播的功能
app.pause();
```

```js
// rtmp 流状态 用于封装开发做 loading 或者显示播放状态

"NetConnection.Connect.Success"; //服务器连接成功
"NetConnection.Connect.Closed"; //连接中断
"NetConnection.Connect.Failed"; //连接失败"
"NetConnection.Connect.Rejected"; //没有权限"
"NetStream.Play.Reset"; //播放列表重置"
"NetStream.Play.Start"; //播放开始"
"NetStream.Buffer.Empty"; //视频正在缓冲"
"NetStream.Buffer.Full"; //缓冲区已填满"
"NetStream.Play.StreamNotFound"; //找不到此视频");
"NetStream.Play.Stop"; //视频播放完成");
"NetStream.Pause.Notify"; //流已暂停"
"NetStream.Unpause.Notify"; //流已恢复"
"NetStream.Seek.Failed"; //搜寻失败"
"NetStream.SeekStart.Notify"; //搜寻开始"
"NetStream.Seek.Notify"; //正在搜寻……"
"NetStream.Seek.Complete"; //搜寻完毕"
"NetStream.Publish.Start"; //发布开始"
"NetStream.Unpublish.Success"; //停止发布"
"NetStream.Record.Start"; //开始录制"
"NetStream.Record.Stop"; //停止录制"
"NetStream.Publish.BadName"; //警告!试图发布已经被他人发布的流"
"NetStream.Play.PublishNotify"; //发布开始,信息已经发送到所有订阅者"); //测试发布端有没在发布
"NetStream.Play.UnpublishNotify"; //发布停止,信息已经发送到所有订阅者"); //测试发布端是否停止了发布
"NetStream.Play.InsufficientBW"; //警告!客户端没有足够的带宽,无法以正常速度播放数据"
```
15 changes: 8 additions & 7 deletions index.as
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@ var nc = null;
var ns = null;
var serverName;
var streamName;
var videoObj = new Video(800, 450);

videoObj.smoothing = true;

function log(value) {
function info(value) {
try {
ExternalInterface.call("console.log", value);
ExternalInterface.call("Ouzzplayer.status", value);
} catch (err) {
// empty
}
}

var videoObj = new Video(800, 450);
videoObj.smoothing = true;

function createLiveStream() {
nc = new NetConnection();
nc.client = this;
nc.addEventListener(NetStatusEvent.NET_STATUS, function(event) {
log("nc: " + event.info.code);
info(event.info.code);
if (event.info.code == "NetConnection.Connect.Success") {
ns = new NetStream(nc);
ns.addEventListener(NetStatusEvent.NET_STATUS, function(event) {
log("ns: " + event.info.code);
info(event.info.code);
});
var nsClientObj = new Object();
ns.client = nsClientObj;
Expand Down Expand Up @@ -84,6 +84,7 @@ try {
ExternalInterface.addCallback("stopLive", destoryLiveStream);
ExternalInterface.addCallback("snapshot", snapshot);
ExternalInterface.addCallback("pause", pause);
ExternalInterface.call("console.log", 'player is ok');
} catch (err) {
// empty
}
Expand Down
Binary file modified index.fla
Binary file not shown.
20 changes: 14 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,26 @@
</div>

<script>
var Ouzzplayer = {
snapshot: function(str) {
var bs64 = `data:image/jpeg;base64,${str}`;
const Ouzzplayer = {
snapshot(str) {
const bs64 = `data:image/jpeg;base64,${str}`;
console.log(bs64);
},
status(code) {
console.log(code);
}
};

const app = document.getElementById("app");

function t(){
app.startLive("rtmp://cyberplayerplay.kaywang.cn/cyberplayer/", "demo201711-L1");
function a() {
app.startLive(
"rtmp://cyberplayerplay.kaywang.cn/cyberplayer/",
"demo201711-L1"
);
}
function s(){

function b() {
app.snapshot();
}
</script>
Expand Down
Binary file modified index.swf
Binary file not shown.

0 comments on commit 82bd61d

Please sign in to comment.