-
Notifications
You must be signed in to change notification settings - Fork 102
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
Sound preference proposal, closes #83 #84
Conversation
Thank you for doing this work! Two requests if you have time @smarek:
|
@ubershmekel cool
This is what I see in "media": {
"reddit_video": {
"fallback_url": "https://v.redd.it/3fqsu5bczj131/DASH_720?source=fallback",
"height": 720,
"width": 1280,
"scrubber_media_url": "https://v.redd.it/3fqsu5bczj131/DASH_96",
"dash_url": "https://v.redd.it/3fqsu5bczj131/DASHPlaylist.mpd",
"duration": 61,
"hls_url": "https://v.redd.it/3fqsu5bczj131/HLSPlaylist.m3u8",
"is_gif": false,
"transcoding_status": "completed"
}
},
I propose this controls layout:
what do you think? |
Then What do you think of that layout? |
js/script.js
Outdated
@@ -334,6 +354,7 @@ $(function () { | |||
// Need to redesign this redditp thing. | |||
pic.type = imageTypes.gifv; | |||
pic.url = pic.data.media.reddit_video.fallback_url; | |||
pic.sound = pic.url.substring(0,pic.url.lastIndexOf('/'))+"/audio"; |
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.
Audio url
This works on v.redd.it urls like https://www.reddit.com/r/WhatsWrongWithYourDog/comments/c3x7cc/doggo_thinks_that_he_is_one_of_them/.json Does not work on gfycat urls like https://www.reddit.com/r/nextfuckinglevel/comments/c3v7b3/looks_so_effortless_but_he_must_have_trained_very/.json |
…-sound2 # Conflicts: # index.html # js/EmbedIt.js # js/script.js Note this only seems to work for video URLs that have sound in them. Not for recombining separate sound file with video file (like reddit). So it only works for imgur.
I re-merged and tested this. This works for a file that has video+audio in it, but not for separate video and audio files like reddit videos. Seems only imgur and gfycat will work with this. I think to make it fully work we'd need to implement something like this JS multiplexing. Which is what I assume reddit video has done: https://medium.com/canal-tech/how-video-streaming-works-on-the-web-an-introduction-7919739f7e1 I'm not sure if we should merge it in when reddit videos don't work. |
Could you maybe create a branch on which we could propose PRs to fix remaining issues with sound, from mentioned "re-merged" branch you already have? Or if you have staging environment somewhere for others to test the sound with (if not, it can be disabled by default and listed under experimental options) Also the "multiplexing" is imho not needed, as you can simply provide different URL that contains MP4 container (audio+video) , or provide separate <video and <audio html tags and sync them using https://stackoverflow.com/a/32323192/492624 or similar techniques |
https://github.com/ubershmekel/redditp/commits/smarek-sound2 You're right. Making separate elements would work too. |
@ubershmekel before i start working on that, would you be cool with using dash.js for playing |
I see the minified file is 577 KB (non-gzipped size). I couldn't find a browser compatibility matrix. Can you explain the cost-benefit? Seems a bit heavy and potentially fragile. |
Given raw-json "reddit_video": {
"fallback_url": "https://v.redd.it/iysd6l20k3941/DASH_480?source=fallback",
"height": 480,
"width": 384,
"scrubber_media_url": "https://v.redd.it/iysd6l20k3941/DASH_96",
"dash_url": "https://v.redd.it/iysd6l20k3941/DASHPlaylist.mpd",
"duration": 19,
"hls_url": "https://v.redd.it/iysd6l20k3941/HLSPlaylist.m3u8",
"is_gif": false,
"transcoding_status": "completed"
} We can either do
I've found conflicted sources, but it seems to me that HLS, being Apple technology, has far more lower support than DASH
However reddit itself (on my device) opens with HLS source <video poster="https://external-preview.redd.it/SZJwCdXt4knnZgskQuE2_C_QDyCXQeDNReuwC-lp5aw.png?width=320&crop=smart&format=pjpg&auto=webp&s=53e709f966bf326c52cb3b64b995cdb2525e2bd8" muted="" preload="auto" class="_1EQJpXY7ExS04odI1YBBlj" src="blob:https://www.reddit.com/b59eb125-a56e-46b4-9d40-9bd09d38b4c4">
<source src="https://v.redd.it/iysd6l20k3941/HLSPlaylist.m3u8" type="application/vnd.apple.mpegURL">
</video> I'd be really grateful if someone could investigate the protocol compatibility between HLS/DASH Relevant tickets |
…xed getNextSlideIndex when no non-nsfw post is available up in queue
…page / comments link
comment links do not contain CORS headers, so it must be loaded via jsonp to bypass the security measures /r/randnsfw, /r/random responses with redirect, and thus must be loaded as jsonp see docs https://www.reddit.com/wiki/random
…external libraries
@ubershmekel I'm quite sorry, but I've solved this ticket and related #104 ticket, but the PR is quite a lot changes, because I was not able to develop efficiently, with so much code issues. Changes i've included along (and the PR is currently mergable without conflicts against master)
I've left the commits un-squashed, but after review, if accepted, i can (or you can) squash some of them together Also, since I've updated this PR and did not create new one against branch smarek-sound2, said branch can be deleted currently |
@@ -435,7 +464,8 @@ $(function () { | |||
$('#titleDiv .collapser').click(); | |||
break; | |||
case A_KEY: | |||
$("#autoNextSlide").prop("checked", !$("#autoNextSlide").is(':checked')); | |||
var $ans = $("#autoNextSlide"); | |||
$ans.prop("checked", !$ans.is(':checked')); |
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.
this is lint issue duplicate jquery selector
if (!rp.photos[i].over18) { | ||
return i; | ||
} | ||
} | ||
return 0; |
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.
here not handling situation where none of available pictures is non-nsfw caused ajax looping, but it's obscure usecase
if (videoTags.length === 1) { | ||
videoTags[0].muted = !rp.settings.sound; | ||
} | ||
var audioTags = document.getElementsByTagName('audio'); |
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.
since for v.redd.it audio tag is separate from video tag, this needs to be checked as well
@@ -342,14 +370,15 @@ $(function () { | |||
// some crossposts don't have a pic.data.media obj? | |||
return; | |||
} | |||
pic.sound = pic.url.substring(0, pic.url.lastIndexOf('/')) + "/audio"; |
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.
this generates audio link for v.redd.it links only
//log("skipped bad extension: " + url); | ||
return false; | ||
} | ||
return rp.settings.goodExtensions.indexOf(extension) >= 0; |
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.
simplify expression lint
return false; | ||
} | ||
} | ||
return !!query.shuffle; |
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.
|
||
}; | ||
|
||
var getStackTrace = function () { |
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.
helper function, unused currently, but very useful in tracing dev issues
@@ -811,7 +850,8 @@ $(function () { | |||
rp.session.loadingNextImages = true; | |||
|
|||
// Note that JSONP requests require `".json?jsonp=?"` here. | |||
var jsonUrl = rp.redditBaseUrl + rp.subredditUrl + ".json?jsonp=?" + rp.session.after + "&" + getVars; | |||
var jsonUrl = rp.redditBaseUrl + rp.subredditUrl + ".json?" + (rp.session.after ? rp.session.after + "&" : "") + getVars; |
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.
jsonp query attribute is added based on below useJsonP classification
Looks like a lot of work. What's the state of affairs? |
What do you mean? |
Co-Authored-By: Yuval Greenfield <[email protected]>
If the single proposed change is everything, i think, it's ready to merge |
Looking at the code, this is all great stuff. I wish I had a test suite that could run through more scenarios. I hope to finish reviewing tomorrow. |
Only thing I'm not satisfied with, is the detection of subreddits, that redirect. There are certainly more than what's hard-coded currently, and I did not find any official list of this kind of subreddits, and detecting whether the call resulted in response from different subreddit (which might not be complete/best solution), is not possible via standard jQuery XHR means (currently being solved here jquery/jquery#4405 ) I propose to solve this in subsequent PR, because ie. |
// is the current solution sadly. | ||
// Note we're still using `jsonp` despite potential issues because | ||
// `http://www.redditp.com/r/randnsfw` wasn't working with CORS for some reason. | ||
// https://github.com/ubershmekel/redditp/issues/104 |
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.
You removed this comment, without providing an explanation for the jsonp
toggling or why did you make the following specific exceptions touseJsonP
. We should pick this up in a future PR.
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.
Sure, it seemed to me that useJsonP with the code, that decides whether it's true or false, is pretty self-explanatory, but as I said, I expect this to be solved better when we tackle the redirected subreddits.
I love that getting a Merging. We'll get the rest sorted later. Thank you so much for all this work @smarek it works beautifully as far as I can tell. |
This is given by response type of the endpoint, when the request is redirected or single-post, the response type does not match application/json, and is blocked by CORB (at least in my chrome dev version 82) Anyway, I'm glad you like the work, and you should probably delete the smarek-sound2 branch now |
No description provided.