only run twenty percent of the time for unauthed users

This commit is contained in:
Anthony 2021-10-11 17:11:58 +03:00
parent 6c463e7310
commit 5b4151bc72
No known key found for this signature in database
GPG key ID: C386D3C93D50E356
2 changed files with 40 additions and 25 deletions

View file

@ -77,6 +77,20 @@ type Props = {
// muted?: boolean,
// };
function hitsTwentyPercent() {
// from 0 - 999
var rand = Math.floor(Math.random() * (1000 + 1));
console.log(rand);
console.log('rand');
if (rand > 799) {
return true;
} else {
return false;
}
}
const videoPlaybackRates = [0.25, 0.5, 0.75, 1, 1.1, 1.25, 1.5, 1.75, 2];
const IS_IOS =
@ -178,7 +192,7 @@ export default React.memo<Props>(function VideoJs(props: Props) {
adUrl,
claimId,
userId,
// allowPreRoll,
allowPreRoll,
shareTelemetry,
replay,
videoTheaterMode,
@ -539,7 +553,10 @@ export default React.memo<Props>(function VideoJs(props: Props) {
// this seems like a weird thing to have to check for here
if (!player) return;
vjs.aniview();
if (allowPreRoll && hitsTwentyPercent()) {
vjs.aniview();
}
// Add various event listeners to player
player.one('play', onInitialPlay);

View file

@ -454,29 +454,27 @@ function VideoViewer(props: Props) {
</>
)}
{!isFetchingAd && (
<VideoJs
adUrl={adUrl}
source={adUrl || source}
sourceType={forcePlayer || adUrl ? 'video/mp4' : contentType}
isAudio={isAudio}
poster={isAudio || (embedded && !autoplayIfEmbedded) ? thumbnail : ''}
onPlayerReady={onPlayerReady}
startMuted={autoplayIfEmbedded}
toggleVideoTheaterMode={toggleVideoTheaterMode}
autoplay={!embedded || autoplayIfEmbedded}
autoplaySetting={autoplayNext}
claimId={claimId}
userId={userId}
allowPreRoll={!embedded && !authenticated}
shareTelemetry={shareTelemetry}
replay={replay}
videoTheaterMode={videoTheaterMode}
playNext={doPlayNext}
playPrevious={doPlayPrevious}
embedded={embedded}
/>
)}
<VideoJs
adUrl={adUrl}
source={adUrl || source}
sourceType={forcePlayer || adUrl ? 'video/mp4' : contentType}
isAudio={isAudio}
poster={isAudio || (embedded && !autoplayIfEmbedded) ? thumbnail : ''}
onPlayerReady={onPlayerReady}
startMuted={autoplayIfEmbedded}
toggleVideoTheaterMode={toggleVideoTheaterMode}
autoplay={!embedded || autoplayIfEmbedded}
autoplaySetting={autoplayNext}
claimId={claimId}
userId={userId}
allowPreRoll={!embedded && !authenticated}
shareTelemetry={shareTelemetry}
replay={replay}
videoTheaterMode={videoTheaterMode}
playNext={doPlayNext}
playPrevious={doPlayPrevious}
embedded={embedded}
/>
</div>
);
}