Skip to content

Commit

Permalink
Merge pull request #64 from eventials/master
Browse files Browse the repository at this point in the history
fix autoSwitch level selector
  • Loading branch information
Germano Fronza authored Aug 29, 2016
2 parents c959a72 + ed60695 commit 006ec27
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ The plugin accepts several **optional** configuration options, such as:
- `playbackType` (default **live** if the source contains live on its URL, **vod** otherwise).
- `bufferTime` (default **0.1**) - How long to buffer before start playing the media.
- `startLevel` (default **-1**) - Initial quality level index.
- `autoSwitch` (default **false**) - Whether video should autoSwitch quality
- `useAppInstance` (default **false**) - Set it to `true` if your source url contains the app instance (not required if the app instance is `_definst_`).
- `proxyType` (default **none**) - Determines which fallback methods are tried if an initial connection attempt to Flash Media Server fails.

Expand Down
Binary file modified dist/assets/RTMP.swf
Binary file not shown.
4 changes: 2 additions & 2 deletions dist/rtmp.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/rtmp.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/rtmp.min.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "clappr-rtmp",
"version": "0.0.16",
"version": "0.0.17",
"description": "RTMP Support for Clappr Player",
"main": "dist/rtmp.js",
"author": "Flávio Ribeiro",
Expand All @@ -20,8 +20,8 @@
"url": "git@github.com:flavioribeiro/clappr-rtmp-plugin.git"
},
"scripts": {
"build_swf": "$(find $HOME/airsdk/ -name mxmlc | head -n1) -default-background-color=0x000000 -default-size=640,360 -language=as3 -output=./public/RTMP.swf -optimize=true -compress=true -use-gpu=true -target-player=11.1 -use-network=false ./src/RTMP.as -library-path+=./src/OSMF.swc",
"release": "node_modules/.bin/webpack --progress -d --optimize-minimize --optimize-dedupe --output-filename rtmp.min.js",
"build_swf": "cd ./src/ && sh build_player.sh",
"release": "node_modules/.bin/webpack --no-minimize && node_modules/.bin/webpack --progress -d --optimize-minimize --optimize-dedupe --output-filename rtmp.min.js",
"build": "node_modules/.bin/webpack --progress",
"watch": "node_modules/.bin/webpack --progress --watch",
"test": "karma start --single-run --browsers Chrome",
Expand Down
Binary file modified public/RTMP.swf
Binary file not shown.
4 changes: 2 additions & 2 deletions public/flash.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<param name="allowFullScreen" value="false">
<param name="wmode" value="<%= wmode %>">
<param name="tabindex" value="1">
<param name=FlashVars value="playbackId=<%= playbackId %>&scaling=<%= scaling %>&bufferTime=<%= bufferTime %>&playbackType=<%= playbackType %>&startLevel=<%= startLevel %>&useAppInstance=<%= useAppInstance %>&proxyType=<%= proxyType %>"/>
<param name=FlashVars value="playbackId=<%= playbackId %>&scaling=<%= scaling %>&bufferTime=<%= bufferTime %>&playbackType=<%= playbackType %>&startLevel=<%= startLevel %>&useAppInstance=<%= useAppInstance %>&proxyType=<%= proxyType %>&autoSwitch=<%= autoSwitch %>"/>
<embed
name="<%= cid %>"
type="application/x-shockwave-flash"
Expand All @@ -22,7 +22,7 @@
swliveconnect="true"
allowfullscreen="false"
bgcolor="#000000"
FlashVars="playbackId=<%= playbackId %>&scaling=<%= scaling %>&bufferTime=<%= bufferTime %>&playbackType=<%= playbackType %>&startLevel=<%= startLevel %>&useAppInstance=<%= useAppInstance %>&proxyType=<%= proxyType %>"
FlashVars="playbackId=<%= playbackId %>&scaling=<%= scaling %>&bufferTime=<%= bufferTime %>&playbackType=<%= playbackType %>&startLevel=<%= startLevel %>&useAppInstance=<%= useAppInstance %>&proxyType=<%= proxyType %>&autoSwitch=<%= autoSwitch %>"
src="<%= swfPath %>"
width="100%"
height="100%">
Expand Down
2 changes: 1 addition & 1 deletion src/RTMP.as
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ package {

mediaPlayer.bufferTime = this.root.loaderInfo.parameters.bufferTime;
mediaPlayer.autoPlay = false;
mediaPlayer.autoDynamicStreamSwitch = startLevel == -1;
mediaPlayer.autoDynamicStreamSwitch = this.root.loaderInfo.parameters.autoSwitch;
mediaPlayer.addEventListener(TimeEvent.CURRENT_TIME_CHANGE, onTimeUpdated);
mediaPlayer.addEventListener(TimeEvent.DURATION_CHANGE, onTimeUpdated);
mediaPlayer.addEventListener(TimeEvent.COMPLETE, onFinish);
Expand Down
29 changes: 26 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default class RTMP extends Flash {
this.options.rtmpConfig.useAppInstance = this.options.rtmpConfig.useAppInstance === undefined ? false : this.options.rtmpConfig.useAppInstance
this.options.rtmpConfig.proxyType = this.options.rtmpConfig.proxyType || 'none'
this.options.rtmpConfig.startLevel = this.options.rtmpConfig.startLevel === undefined ? -1 : this.options.rtmpConfig.startLevel
this.options.rtmpConfig.autoSwitch = this.options.rtmpConfig.autoSwitch === undefined ? false : this.options.rtmpConfig.autoSwitch
this.addListeners()
this._setupPlaybackType()
}
Expand Down Expand Up @@ -62,6 +63,11 @@ export default class RTMP extends Flash {

set currentLevel(level) {
this.el.setLevel(level);

if (level === -1 && level !== this.currentLevel) {
this.trigger(Events.PLAYBACK_LEVEL_SWITCH_END)
this.trigger(Events.PLAYBACK_BITRATE, {level: this.currentLevel})
}
}

get autoSwitchLevels() {
Expand Down Expand Up @@ -155,8 +161,20 @@ export default class RTMP extends Flash {
}

render() {
this.$el.html(this.template({ cid: this.cid, swfPath: this.swfPath, playbackId: this.uniqueId, wmode: this.options.rtmpConfig.wmode, scaling: this.options.rtmpConfig.scaling,
bufferTime: this.options.rtmpConfig.bufferTime, playbackType: this.options.rtmpConfig.playbackType, startLevel: this.options.rtmpConfig.startLevel, useAppInstance: this.options.rtmpConfig.useAppInstance, proxyType: this.options.rtmpConfig.proxyType }))
this.$el.html(this.template({
cid: this.cid,
swfPath: this.swfPath,
playbackId: this.uniqueId,
wmode: this.options.rtmpConfig.wmode,
scaling: this.options.rtmpConfig.scaling,
bufferTime: this.options.rtmpConfig.bufferTime,
playbackType: this.options.rtmpConfig.playbackType,
startLevel: this.options.rtmpConfig.startLevel,
autoSwitch: this.options.rtmpConfig.autoSwitch,
useAppInstance: this.options.rtmpConfig.useAppInstance,
proxyType: this.options.rtmpConfig.proxyType
}))

if (Browser.isIE) {
this.$('embed').remove()
if (Browser.isLegacyIE) {
Expand Down Expand Up @@ -189,7 +207,12 @@ export default class RTMP extends Flash {
_reporLevels() {
if (this.isDynamicStream) {
if (this.levels) {
this.trigger(Events.PLAYBACK_LEVELS_AVAILABLE, this.levels, this.options.rtmpConfig.startLevel)
if (this.options.rtmpConfig.autoSwitch === true) {
this.trigger(Events.PLAYBACK_LEVELS_AVAILABLE, this.levels, -1)
this.trigger(Events.PLAYBACK_BITRATE, {level: this.currentLevel})
} else {
this.trigger(Events.PLAYBACK_LEVELS_AVAILABLE, this.levels, this.options.rtmpConfig.startLevel)
}
}
}
}
Expand Down

0 comments on commit 006ec27

Please sign in to comment.