Skip to content

Commit

Permalink
fix: rtmp flash play
Browse files Browse the repository at this point in the history
  • Loading branch information
halwu(吴浩麟) committed May 29, 2017
1 parent 795901f commit a5d180d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 50 deletions.
2 changes: 1 addition & 1 deletion doc/live/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import '../index.scss';

const ROOT = (
<div className="reflv-wrap">
<h1>直播方案对比</h1>
<h1>常见直播方案对比</h1>
<div>

<ReDemo doc="RTMP">
Expand Down
Binary file modified doc/live/player.swf
Binary file not shown.
63 changes: 14 additions & 49 deletions doc/live/rtmp.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,23 @@ import React, { PureComponent } from 'react';
import swfobject from 'swfobject';
import player from './player.swf';

window.rtmpPlayerHandleEmit = function (event) {
switch (event.kind) {
case "connect":
case "disconnect":
case "publish":
case "status":
case "error":
rtmpPlayerLog("got event", event)
break
default:
rtmpPlayerLog(event)
}
}

window.rtmpPlayerLog = function (log) {
console.info('rtmp-player', log);
}

export class RTMP extends PureComponent {

componentDidMount() {
const swfVersionStr = "11.4.0"
, xiSwfUrlStr = "playerProductInstall.swf"
, flashvars = {}
, params = {}
, attributes = {}

params.allowscriptaccess = "sameDomain"
params.allowfullscreen = "true"
attributes.id = "rtmp-player"
attributes.name = "rtmp-player"
attributes.align = "middle"
swfobject.embedSWF(
player, "rtmp-player", "1000", "500",
swfVersionStr, xiSwfUrlStr,
flashvars, params, attributes,
function (embedEvent) {
if (embedEvent.success) {
// need to wait a bit until initialization finishes
setTimeout(function () {
embedEvent.ref.setOptions({
jsLogFunction: "rtmpPlayerLog",
jsEmitFunction: "rtmpPlayerHandleEmit",
serverURL: "rtmp://localhost/live",
streamName: "movie"
}
);
embedEvent.ref.play();
}, 3000);
}
}
)
const soFlashVars = {
src: 'rtmp://localhost/live/movie',
streamType: 'live',
autoPlay: "true",
controlBarAutoHide: "true",
controlBarPosition: "bottom"
};
const swfVersionStr = "10.3.0";
const xiSwfUrlStr = "swfs/playerProductInstall.swf";
const params = {
quality: 'high',
allowscriptaccess: 'sameDomain',
};
swfobject.embedSWF(player, 'rtmp-player', "968", "549", swfVersionStr, xiSwfUrlStr, soFlashVars, params);
}

render() {
Expand Down

0 comments on commit a5d180d

Please sign in to comment.