Skip to content
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

conditionally hide controls #22

Merged
merged 1 commit into from
Aug 14, 2015
Merged

conditionally hide controls #22

merged 1 commit into from
Aug 14, 2015

Conversation

cvan
Copy link
Contributor

@cvan cvan commented Aug 2, 2015

this is dependent on the foundational work in PR #20 for allowing overrides via URL. I'd recommend reviewing and merging that one first. 😃

though issue #15 requests to "have properties we can set via JS," I think allowing these overrides from a URL is a good first step.

once there is a standalone bundle that's generated (see issue #21), I can see how it might be useful to initialise the player without the video controls via like so:

eleVRWebPlayer({
  controls: false
});

here is a list of the items addressed in this PR:

  • removes unused #forkongithub in index.html and css/forkme.css stylesheet (was interfering with the height of the #video-container when the #video-controls were hidden)
  • prevents video controls (in #video-container) and event listeners (controls.create()) from getting initialised if controls are to be hidden on page load (e.g., by passing ?controls=false or #{"controls": false})
    • admittedly, all the if statements in controls.js does add some cruft. could just simply hide the controls using CSS, but thought this would be a better approach - to just not expose the global references if they don't get rendered (though if the hash changes or a postMessage message is received that says to disable the controls, the global references are set and everything just works)
  • fixes container dimensions so they get recalculated on window resize
  • fixes case where querystring would persist when postMessage would set window.location.hash but would leave window.location.search, thereby confusing which settings to read from (could uplift change to PR add ability to load external video URLs (via querystring, hash, postMessage) #20)

test case

to test how this would work from an iframe, drop this into a file like iframe.html in the root directory:

<iframe src="/?controls=false&amp;autoplay=1&amp;video=http://cdn2.vrideo.com/prod_videos/v1/mYNVcD6_480p_full.mp4" style="border: 0; position: absolute; left: 0; top: 0; height: 100%; width: 100%" allowfullscreen></iframe>

and to test muting, open the JS Console and run this command:

window.postMessage({autoplay: true, mute: true}, '*')

and to unmute:

window.postMessage({autoplay: true, unmute: true}, '*')

feedback very welcome. thanks! 😺

@cvan
Copy link
Contributor Author

cvan commented Aug 4, 2015

updated patch to remove all conditional logic and just always call function to set up query selectors.

@cvan
Copy link
Contributor Author

cvan commented Aug 11, 2015

will update now that #20 has been merged

@cvan
Copy link
Contributor Author

cvan commented Aug 11, 2015

ready for re-review for this now that #20, #24, #25 are merged - and I just opened #26 to split unrelated things out of this PR.

also added sample usage to README.

@hawksley
Copy link
Owner

Yay! Thanks for updating the readme as well. :)

hawksley added a commit that referenced this pull request Aug 14, 2015
@hawksley hawksley merged commit 7e0d599 into hawksley:master Aug 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants