Skip to content

Commit dfb90be

Browse files
mshaaban0mderrick
authored andcommitted
Proposal . Show 2 channels if video length less than 1 hour (#104)
* Show 2 channels if video length less than 1 hour * enhance video duration appearance
1 parent abc274b commit dfb90be

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/DefaultPlayer/Time/Time.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ const formatTime = (seconds) => {
77
? 0
88
: Math.floor(seconds);
99
date.setSeconds(seconds);
10-
return date.toISOString().substr(11, 8);
10+
const duration = date.toISOString().substr(11, 8).replace(/^0{1,2}:?0{0,1}/,'');
11+
return duration;
1112
};
1213

1314
export default ({ currentTime, duration, className }) => {

src/DefaultPlayer/Time/Time.test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,35 +28,35 @@ describe('Time', () => {
2828
duration: 10
2929
});
3030
expect(component.find(`.${styles.duration}`).text())
31-
.toEqual('00:00:10');
31+
.toEqual('0:10');
3232
});
3333

3434
it('shows current video elapsed time', () => {
3535
component.setProps({
3636
currentTime: 10
3737
});
3838
expect(component.find(`.${styles.current}`).text())
39-
.toEqual('00:00:10');
39+
.toEqual('0:10');
4040
});
4141

4242
it('can handle minutes, hours and seconds', () => {
4343
component.setProps({
4444
currentTime: 60 * 2
4545
});
4646
expect(component.find(`.${styles.current}`).text())
47-
.toEqual('00:02:00');
47+
.toEqual('2:00');
4848

4949
component.setProps({
5050
currentTime: 60 * 60 * 3
5151
});
5252
expect(component.find(`.${styles.current}`).text())
53-
.toEqual('03:00:00');
53+
.toEqual('3:00:00');
5454

5555
component.setProps({
5656
currentTime: 60 * 60 * 3 + 72
5757
});
5858
expect(component.find(`.${styles.current}`).text())
59-
.toEqual('03:01:12');
59+
.toEqual('3:01:12');
6060
});
6161

6262
it('fails gracefully and shows 00:00:00 when video is greater than 24 hours', () => {
@@ -66,26 +66,26 @@ describe('Time', () => {
6666
currentTime: 86401
6767
});
6868
expect(component.find(`.${styles.current}`).text())
69-
.toEqual('00:00:00');
69+
.toEqual('0:00');
7070

7171
component.setProps({
7272
currentTime: 86400
7373
});
7474
expect(component.find(`.${styles.current}`).text())
75-
.toEqual('00:00:00');
75+
.toEqual('0:00');
7676
});
7777

78-
it('fails gracefully and shows 00:00:00 when not given a number', () => {
78+
it('fails gracefully and shows 00:00 when not given a number', () => {
7979
component.setProps({
8080
currentTime: null
8181
});
8282
expect(component.find(`.${styles.current}`).text())
83-
.toEqual('00:00:00');
83+
.toEqual('0:00');
8484

8585
component.setProps({
8686
currentTime: undefined
8787
});
8888
expect(component.find(`.${styles.current}`).text())
89-
.toEqual('00:00:00');
89+
.toEqual('0:00');
9090
});
9191
});

0 commit comments

Comments
 (0)