-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
161 lines (136 loc) · 7.45 KB
/
index.js
File metadata and controls
161 lines (136 loc) · 7.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
import React, { Component, PropTypes } from 'react';
import Video from 'components/media/Video';
class VideoModuleDemo extends Component {
static defaultProps = {
"titles": [
"Stream 1",
"Stream 2",
"Stream 3",
// "Stream 4",
],
"streamUrls": [
"https://channels-1.video.franklyinc.com/out/i/15812.m3u8",
"https://channels-1.video.franklyinc.com/out/i/19735.m3u8",
"https://f3ba597f7d4949af9ea7f7405594adea.mediatailor.us-east-1.amazonaws.com/v1/master/1d83eb30e3b0c3924fb4496062b92664bd531371/Fox-WAGA-MediaPackage-Beta/index.m3u8",
// "https://f3ba597f7d4949af9ea7f7405594adea.mediatailor.us-east-1.amazonaws.com/v1/master/1d83eb30e3b0c3924fb4496062b92664bd531371/Fox-WAGA-MediaPackage-Beta/index.m3u8",
],
"posterUrls": [
"https://FRANKLYDEMO.images.worldnow.com/images/18020840_G.jpeg",
"https://FRANKLYDEMO.images.worldnow.com/images/18018385_G.jpeg",
"https://FRANKLYDEMO.images.worldnow.com/images/18055016_G.jpeg",
// "https://FRANKLYDEMO.images.worldnow.com/images/18055016_G.jpeg",
]
}
constructor(props) {
super(props);
this.state = {
video: ''
};
this.updateVideo = this.updateVideo.bind(this);
// this.clearVideo = this.clearVideo.bind(this);
// this.updateVideo('https://channels-1.video.franklyinc.com/out/i/6989.m3u8');
// this.updateVideo('https://1cfed095bf82411d8d4a38bed11fa674.mediatailor.us-east-1.amazonaws.com/v1/master/1d83eb30e3b0c3924fb4496062b92664bd531371/Fox-WAGA/83.m3u8');
console.log("*** this.props : ", this.props);
// this.videoPlaylist = [
// 'https://channels-1.video.franklyinc.com/out/i/15812.m3u8',
// 'https://channels-1.video.franklyinc.com/out/i/19735.m3u8',
// 'https://f3ba597f7d4949af9ea7f7405594adea.mediatailor.us-east-1.amazonaws.com/v1/master/1d83eb30e3b0c3924fb4496062b92664bd531371/Fox-WAGA-MediaPackage-Beta/index.m3u8',
// 'https://1cfed095bf82411d8d4a38bed11fa674.mediatailor.us-east-1.amazonaws.com/v1/master/1d83eb30e3b0c3924fb4496062b92664bd531371/Fox-WAGA/83.m3u8',
// 'https://bitdash-a.akamaihd.net/content/MI201109210084_1/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8',
// 'https://video-dev.github.io/streams/x36xhzz/x36xhzz.m3u8'
// ]
// this.videoPlaylist = this.props.streamUrls;
}
shouldComponentUpdate() {
console.log("*** shouldComponentUpdate()");
return false;
}
componentWillMount() { // set initial video
console.log("*** componentWillMount()");
const url = this.props.streamUrls[0];
const wNVideoCanvasProps = [{
SetFlashLiveStream: [{
strUrl: url,
strHeadline: 'Livestream',
strAdTag: 'News',
hasPreroll: false,
strSummaryImageUrl: '',
mobileStreams: [{
url: '',
type: 'video/mp4'
}, {
url: '',
type: 'video/mp4'
}, {
url: '',
type: 'video/mp4'
}]
}]
}];
this.setState({
video: <Video clipId={1} autoPlay={true} wNVideoCanvasProps={wNVideoCanvasProps} />
});
}
// async clearVideo() {
// console.log("*** clearVideo()");
// if (FranklyVideoPlayerList && FranklyVideoPlayerList[0] && FranklyVideoPlayerList[0].playerInfo && FranklyVideoPlayerList[0].playerInfo.playerId) {
// videojs(FranklyVideoPlayerList[0].playerInfo.playerId).dispose();
// FranklyVideoPlayerList[0].enabled = false;
// FranklyVideoPlayerList.splice(0,1);
// await this.setState({ video: '' }); // clear the current video
// }
// }
async updateVideo(id) {
console.log("*** updateVideo(), id:", id + " url: " + this.props.streamUrls[id]);
if (FranklyVideoPlayerList && FranklyVideoPlayerList[0] && FranklyVideoPlayerList[0].playerInfo && FranklyVideoPlayerList[0].playerInfo.playerId) {
// videojs(FranklyVideoPlayerList[0].playerInfo.playerId).src(this.props.streamUrls[id]);
// videojs(FranklyVideoPlayerList[0].playerInfo.playerId).play(); // this is a hack. no update to analytics/etc.
// // FranklyVideoPlayerList[0].playerInfo.canFireResumeAfterPause = false;
// // FranklyVideoPlayerList[0].playerInfo.loadInitialVideo(true);
autoplayPossible = true; // hack fix for Chrome to play on second video. can be removed after forceAutoplay is added in legacy PR #487
var franklyStreamPlayer = FranklyVideoPlayerList[0].playerInfo;
var player_id = franklyStreamPlayer.playerId;
console.log("*** updateVideo :: franklyStreamPlayer : ", franklyStreamPlayer);
console.log("*** updateVideo :: this.props.streamUrls[id] : ", this.props.streamUrls[id]);
// franklyStreamPlayer.currentClip.content[0].src = this.props.streamUrls[id]; // this is already set at the end of loadClip
franklyStreamPlayer.vars.liveStreamUrl = this.props.streamUrls[id];
franklyStreamPlayer.loadInitialVideo(true); // true == force autoplay
}
}
render(){
this.vidContainerStyles = {
gridTemplateAreas: ""
};
var vidList = this.props.streamUrls.map(function(streamUrl, index){
this.vidContainerStyles.gridTemplateAreas += "'main vid" + index + "' ";
if (this.props.streamUrls.length > 3 && index > 2) { // add extra 4th row
this.vidContainerStyles.gridTemplateRows += "1fr ";
}
var vidThumbStyles = {
backgroundImage: 'linear-gradient(0deg,rgba(0,0,0,.5),transparent), url("'+ this.props.posterUrls[index] +'")',
gridArea: 'vid' + index
}
return (
<div style={vidThumbStyles} className="vidThumb" onClick={() => this.updateVideo(index)} >
<img src="data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0ia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Pgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8L3N2Zz4K" />
<br/>{this.props.titles[index]}
</div>
);
}.bind(this));
for (var i = 1; i <= 3; i++) { // add empty cells if less than 3 streams
if (this.props.streamUrls.length < i) {
this.vidContainerStyles.gridTemplateAreas += "'main .'";
}
}
console.log("*** this.vidContainerStyles: ", this.vidContainerStyles);
return (
<div className='VideoModuleDemo'>
<div className="vidContainer" style={this.vidContainerStyles}>
<div className="vidMain" style={{gridArea: 'main'}}><span className='VideoModuleDemo-Video'>{this.state.video}</span></div>
{vidList}
</div>
</div>
);
}
}
export default VideoModuleDemo;