Skip to content

Commit 9347c7f

Browse files
Merge pull request #52 from eventials/master
Compatible with latest Clappr version (0.2.58)
2 parents 858f76e + 15d812f commit 9347c7f

10 files changed

+92
-59
lines changed

dist/assets/RTMP.swf

37 Bytes
Binary file not shown.

dist/rtmp.js

+5-31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rtmp.min.js

+16-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rtmp.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
import RTMP from './src/main'
2-
module.exports = window.RTMP = RTMP;
1+
export default require('./src/main.js')

package.json

+16-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "clappr-rtmp",
3-
"version": "0.0.12",
3+
"version": "0.0.13",
44
"description": "RTMP Support for Clappr Player",
55
"main": "dist/rtmp.js",
66
"author": "Flávio Ribeiro",
@@ -21,21 +21,28 @@
2121
},
2222
"scripts": {
2323
"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",
24-
"release": "node_modules/webpack/bin/webpack.js --progress -d -p --optimize-minimize --optimize-dedupe --output-filename rtmp.min.js",
25-
"build": "node_modules/webpack/bin/webpack.js"
24+
"release": "node_modules/.bin/webpack --progress -d --optimize-minimize --optimize-dedupe --output-filename rtmp.min.js",
25+
"build": "node_modules/.bin/webpack --progress",
26+
"watch": "node_modules/.bin/webpack --progress --watch",
27+
"test": "karma start --single-run --browsers Chrome",
28+
"start": "node_modules/.bin/webpack-dev-server --content-base public/ --output-public-path /latest --hot",
29+
"lock": "rm -rf npm-shrinkwrap.json node_modules && npm install --silent && npm shrinkwrap"
2630
},
2731
"dependencies": {
2832
"clappr": "latest"
2933
},
3034
"devDependencies": {
31-
"babel-core": "^6.5.1",
32-
"babel-loader": "^6.2.2",
33-
"babel-plugin-add-module-exports": "^0.1.2",
34-
"babel-preset-es2015": "^6.5.0",
35-
"transfer-webpack-plugin": "^0.1.4",
35+
"babel-core": "^5.8.25",
36+
"babel-loader": "^5.3.2",
37+
"css-loader": "^0.18.0",
3638
"html-loader": "^0.3.0",
39+
"mocha": "^2.3.2",
40+
"mocha-loader": "^0.7.1",
41+
"node-sass": "^3.3.3",
3742
"sass-loader": "^3.1.1",
3843
"raw-loader": "^0.5.1",
39-
"webpack": "^1.12.2"
44+
"style-loader": "^0.12.4",
45+
"webpack": "^1.12.2",
46+
"transfer-webpack-plugin": "^0.1.4"
4047
}
4148
}

public/RTMP.swf

37 Bytes
Binary file not shown.

src/RTMP.as

+20-1
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,31 @@ package {
125125
ExternalInterface.addCallback("getPosition", getPosition);
126126
ExternalInterface.addCallback("getDuration", getDuration);
127127
ExternalInterface.addCallback("getCurrentLevel", getCurrentLevel);
128+
ExternalInterface.addCallback("getBytesLoaded", getBytesLoaded);
129+
ExternalInterface.addCallback("getBytesTotal", getBytesTotal);
128130
ExternalInterface.addCallback("getNumLevels", getNumLevels);
129131
ExternalInterface.addCallback("getBitrateForLevel", getBitrateForLevel);
130132
ExternalInterface.addCallback("isDynamicStream", isDynamicStream);
131133
ExternalInterface.addCallback("isAutoSwitchLevels", isAutoSwitchLevels);
132134
}
133135

136+
private function getBytesTotal():Number {
137+
if (netStream) {
138+
return netStream.bytesTotal;
139+
}
140+
else {
141+
return 0;
142+
}
143+
}
144+
private function getBytesLoaded():Number {
145+
if (netStream) {
146+
return netStream.bytesLoaded;
147+
}
148+
else {
149+
return 0;
150+
}
151+
}
152+
134153
private function onTraitAdd(event:MediaElementEvent):void {
135154
if (mediaElement.hasTrait(MediaTraitType.LOAD)) {
136155
netStreamLoadTrait = mediaElement.getTrait(MediaTraitType.LOAD) as NetStreamLoadTrait;
@@ -221,7 +240,7 @@ package {
221240
} else {
222241
mediaPlayer.play();
223242
}
224-
} catch {
243+
} catch (err:Error) {
225244
playbackState = "ERROR";
226245
_triggerEvent('statechanged');
227246
}

src/main.js

+16-12
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,9 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
import {Browser} from 'clappr'
6-
import {Events} from 'clappr'
7-
import {Flash} from 'clappr'
8-
import {Mediator} from 'clappr'
9-
import {Styler} from 'clappr'
10-
import template from 'clappr/src/base/template'
11-
12-
import flashHTML from 'html!../public/flash.html'
5+
import {Browser, Events, Flash, Mediator, Styler, UICorePlugin, template} from 'clappr'
6+
7+
import flashHTML from '../public/flash.html'
138
import flashStyle from '!raw!sass!../public/flash.scss'
149

1510
export default class RTMP extends Flash {
@@ -27,14 +22,14 @@ export default class RTMP extends Flash {
2722

2823
constructor(options) {
2924
super(options)
30-
this.options = options
3125
this.options.rtmpConfig = this.options.rtmpConfig || {}
3226
this.options.rtmpConfig.swfPath = this.options.rtmpConfig.swfPath || '//cdn.jsdelivr.net/clappr.rtmp/latest/assets/RTMP.swf'
3327
this.options.rtmpConfig.wmode = this.options.rtmpConfig.wmode || 'transparent' // Default to transparent wmode - IE always uses gpu as per objectIE
3428
this.options.rtmpConfig.bufferTime = this.options.rtmpConfig.bufferTime === undefined ? 0.1 : this.options.rtmpConfig.bufferTime
3529
this.options.rtmpConfig.scaling = this.options.rtmpConfig.scaling || 'letterbox'
3630
this.options.rtmpConfig.playbackType = this.options.rtmpConfig.playbackType || this.options.src.indexOf('live') > -1
3731
this.options.rtmpConfig.startLevel = this.options.rtmpConfig.startLevel === undefined ? -1 : this.options.rtmpConfig.startLevel
32+
this.addListeners()
3833
this._setupPlaybackType()
3934
}
4035

@@ -47,11 +42,19 @@ export default class RTMP extends Flash {
4742
}
4843

4944
get currentLevel() {
50-
return this.el.getCurrentLevel();
45+
if (this._isReadyState) {
46+
return this.el.getCurrentLevel();
47+
}
48+
49+
return undefined;
5150
}
5251

5352
get numLevels() {
54-
return this.el.getNumLevels();
53+
if (this._isReadyState) {
54+
return this.el.getNumLevels();
55+
}
56+
57+
return undefined;
5558
}
5659

5760

@@ -122,6 +125,7 @@ export default class RTMP extends Flash {
122125

123126
_levelChange() {
124127
this.trigger(Events.PLAYBACK_LEVEL_SWITCH_END)
128+
this.trigger(Events.PLAYBACK_BITRATE, {level: this.currentLevel})
125129
}
126130

127131
findLevelBy(id) {
@@ -145,7 +149,7 @@ export default class RTMP extends Flash {
145149
this.settings.right = ["fullscreen", "volume"]
146150
}
147151

148-
this.trigger(Events.PLAYBACK_SETTINGSUPDATE)
152+
this.trigger(Events.PLAYBACK_SETTINGSUPDATE, this.name)
149153
}
150154

151155
render() {

webpack.config.js

+17-2
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,25 @@ module.exports = {
2525
loader: 'babel',
2626
query: {
2727
compact: true,
28-
presets: ['es2015'],
2928
}
3029
},
31-
{ test: /\.(png|woff|eot|ttf|swf)/, loader: 'file-loader' }
30+
{
31+
test: /\.scss$/,
32+
loaders: ['css', 'sass?includePaths[]='
33+
+ path.resolve(__dirname, './node_modules/compass-mixins/lib')
34+
+ '&includePaths[]='
35+
+ path.resolve(__dirname, './node_modules/clappr/src/base/scss')
36+
+ '&includePaths[]='
37+
+ path.resolve(__dirname, './src/base/scss')
38+
],
39+
include: path.resolve(__dirname, 'src'),
40+
},
41+
{
42+
test: /\.html/, loader: 'html?minimize=false'
43+
},
44+
{
45+
test: /\.(png|woff|eot|ttf|swf)/, loader: 'file-loader'
46+
}
3247
],
3348
},
3449
resolve: {

0 commit comments

Comments
 (0)