-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Basic UI for Live #1121
Basic UI for Live #1121
Changes from 2 commits
bc47c5e
2fb10cb
554c003
f940bef
2dd8284
6a093d6
10f21cc
2c5d4d5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* Displays the live indicator | ||
* TODO - Future make it click to snap to live | ||
* @param {vjs.Player|Object} player | ||
* @param {Object=} options | ||
* @constructor | ||
*/ | ||
vjs.LiveDisplay = vjs.Component.extend({ | ||
init: function(player, options){ | ||
vjs.Component.call(this, player, options); | ||
} | ||
}); | ||
|
||
vjs.LiveDisplay.prototype.createEl = function(){ | ||
var el = vjs.Component.prototype.createEl.call(this, 'div', { | ||
className: 'vjs-live-controls vjs-control' | ||
}); | ||
|
||
this.contentEl_ = vjs.createEl('div', { | ||
className: 'vjs-live-display', | ||
innerHTML: '<span class="vjs-control-text">LIVE</span>LIVE', | ||
'aria-live': 'off' | ||
}); | ||
|
||
el.appendChild(this.contentEl_); | ||
|
||
return el; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -507,6 +507,13 @@ vjs.Player.prototype.onDurationChange = function(){ | |
if (duration) { | ||
this.duration(duration); | ||
} | ||
|
||
// Determine if the stream is live and propagate styles down to UI. | ||
if (duration <= 0 || duration === window.INFINITY) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are there specific cases where if duration == 0, it means live? In other cases it just means we don't have the duration yet, so I think that could cause cases where it says it's live when it isn't. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. That should probably be duration < 0, not <=. On some platforms RTMP and HDS live can report -1 which is why I put that in there. |
||
this.addClass('vjs-live'); | ||
} else { | ||
this.removeClass('vjs-live'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will probably cause styles to get recalculated on the player every time there is a duration change. That might be expensive. Have you checked this out on mobile devices yet? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not yet, setting up HLS live testing right now. I could just as easily set this to check on loadstart if we feel this is too heavy. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in most segmented delivery formats (HLS/HDS/DASH) duration change happens regularly in live as the manifest updates on polling, so @dmlap 's concern is legitimate. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok got it. Is the duration even used in that case then? Should we not even be triggering durationchange in a live scenario? I guess whatever iOS does we should be ready for either way. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. duration is used in any live with DVR scenarios. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the live with DVR scenario, what does the duration look like? Would it be caught by the current conditional (duration < 0 || duration === window.INFINITY)? At what point do we know for sure if the video is live or not? Is it after Can we outline the different live scenarios, how we know they're live, and at what point we have that information available? |
||
} | ||
}; | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the second
LIVE
outside of thevjs-control-text
needed? Would be better to take it out.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind. Didn't realize other controls were also doing it and that it was mostly for screen readers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually yeah, in this case the screen reader would read both, "LIVELIVE". If you look at how the durationDisplay works, the control text is used to describe what the value is.
So in this case we might have something like
Not exactly sure on the right term to use there.