Results 1 to 4 of 4

Thread: Location-based video

  1. #1
    Join Date
    Jan 2013

    Location-based video

    Hi chaps,

    I'm looking to put a video on a website that is only accessible if you are within a certain location. I have looked briefly at location APIs but i am still unsure as to how to incorporate this concept into HTML.

    Any help would be very much appreciated

  2. #2
    Join Date
    Mar 2005
    Behind you...
    You have a couple of options here, each with their pros and cons.

    Firstly, you could make use of the new Geolocation additions to HTML5. This unfortunately means it won't be supported in all browsers, but to be fair all major browsers do support this (IE starting at 9+). It's always a terrible practice to exclude any set of users based on something such as a browser but it's 2012 and I can see too many logical reasons for using and substandard browser.
    Anyway, using HTML5 Geolocation you can find a user's location with more accuracy than most other methods. It does however require the user to allow your site to actually get their location so this would really depend on what kind of content is being served on the page. Since the access for the video seems to be somewhat exclusive it may not be such a bad thing to have the eligible users first validate their location by allowing the browser to use HTML5 Geolocation.

    The next option is the old-fashioned IP-address geolocation. This is far less accurate and would actually cost you a bit to get more accurate results. There also tends to be limits when using online databases to locate IPs so if there is a lot of traffic going to such a page you might be out of luck with this method. But there are a number of services (free and paid) that give you access to databases which can locate a user based on the IP which would of course allow you to automatically get information about a user's location without the need to first ask the user (like with HTML5 Geolocation) and if you do this directly on the server-side of your site (as opposed to something like AJAX) you can handle everything before any content is loaded on to the user's page.

    The last option is a terrible one for the most part, but you could always have the users input their location. Now if your site has some sort of account system this would be a bit more reliable as you should be able to gather at least some basic data on a user's location such as country and possibly even state/region (without being too invasive with things such as a full street address). But of course users can lie and so it's a bit harder to enforce honest input of information. Without any sort of account system you would be essentially asking a user to input their location (to an extent) and then either telling them "Sorry, no soup for you!" or "Here you go, vidyas!" Most people would be able to realize they could just enter one of your valid locations in to the field and view the content.

    There are potentially other solutions or even a mix of the solutions above that could be implemented. In the end though it'll come down to what you need and how you want to go about gathering such information from your user-base.
    "Given billions of tries, could a spilled bottle of ink ever fall into the words of Shakespeare?"

  3. #3
    Join Date
    Jan 2013
    Thanks a lot, very informative stuff.

    I think I will go with the HTML5 geolocation option on this basis.

    I've looked around and found a lot of examples of its implementation using Google maps, which is great fun, but it's tricky identifying how exactly to implement it as sort of an 'if' function - so if the viewer is within certain coordinates then the content of the site is displayed.

    There is some mention of this scattered across the web but minimal specific support, so I was wondering whether anybody could point me in the right direction?

    Thanks again

  4. #4
    Join Date
    Mar 2005
    Behind you...
    I haven't personally messed with the new HTML5 Geolocation API much but depending on what information you need about the location these links may be your solution:
    Get Country from Lat and Long: http://stackoverflow.com/questions/4...tude-longitude
    Get City from Lat and Long: http://stackoverflow.com/questions/6...-get-city-name

    I do apologize for not being able to post some direct code that gives you your answer, but those two links include everything you need to return a country or city name given latitude and longitude coordinates from the HTML5 Geolocation API, it just may require some slight tweaks or changes to work it in to your page/system.

    Anyway, I assume that if you had the country or city it would be much easier to implement this in to an if statement since you could run it against an array of accepted (or rejected) countries or cities. It would be possible to do this with the actual coordinates but a bit more involved since you'd be dealing with all sorts of ranges that you'd have to research a bit to make sure they are accurate for the proper areas.
    "Given billions of tries, could a spilled bottle of ink ever fall into the words of Shakespeare?"

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.15150 seconds
  • Memory Usage 2,863KB
  • Queries Executed 15 (?)
More Information
Template Usage (32):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (4)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (71):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates