www.webdeveloper.com
Results 1 to 10 of 10

Thread: custom video controls hide show code problem

  1. #1
    Join Date
    Apr 2013
    Posts
    44

    Question custom video controls hide show code problem

    hi,
    i have a video and i created custom controls for this video.
    i want to show custom controls,when mouse is over then hide controls,when mouse is out.
    i wrote some code for this but it makes this even once.the second and more hovers,controls remains hidden.

    here is my code:

    Code:
    function initializePlayer()
    	{
    control=document.getElementById("controls");
    control.addEventListener("mouseover",hoverVideo,false);
    }
    window.onload=initializePlayer;
    function hoverVideo(e)
    		{
    			control.style.visibility="visible";
    			control.addEventListener("mouseout",hideVideo,false);
    		}
    		function hideVideo(e)
    		{
    			e.preventDefault();
    			control.style.visibility="hidden";
    		}
    how can i solve this problem?

  2. #2
    Join Date
    Jun 2008
    Posts
    106
    It could be because you add several mouseout listeners. It's hard to tell.

    Try this. If this doesn't work, you probably have a different problem.

    Code:
    var control;
    
    function initializePlayer() {
        control = document.getElementById("controls");
        control.addEventListener("mouseover", showVideo, false);
        control.addEventListener("mouseout", hideVideo, false);
    }
    
    function showVideo(event) {
        control.style.visibility = "visible";
    }
    
    function hideVideo(event) {
        control.style.visibility = "hidden";
    }
    
    window.onload = initializePlayer;

  3. #3
    Join Date
    Apr 2013
    Posts
    44
    i try your code but it is not working too.

  4. #4
    Join Date
    Jul 2013
    Posts
    24
    I'd say make nested if elses into a loop . Either way yoyr gona need a loop so it reactivates the javascript that's already finished. It won't run the code twice unless you tell it to

  5. #5
    Join Date
    Jul 2013
    Posts
    24
    At the end of his functioms make a call back to th e original function. That should work

  6. #6
    Join Date
    Apr 2013
    Posts
    44
    ok i solve auto hide problem.
    but i have another problem too.
    i have some buttons outside the video.
    like:
    Code:
    <div id="gallery">
    	    <div id="slides">
    	      <div class="slide" >
               <div id="contain">
            		<video id="video" width="900" height="320" autoplay  autohide="3">
                		<source src="video/The-Big-White---Sample.webm" type="video/webm"/>
                    	<source src="video/big_buck_bunny_1080p_stereo.ogg" type="video/ogg"/>
      			<source  src="video/The-Big-White---Sample.mp4" type="video/mp4"/>
      			<source src="video/Examplevideo.ogv" type="video/ogg"/>
    		</video>
                	<div id="controls" >
                	    <button id="playpause"></button>
                        <input id="seekslider" type="range" min="0" max="100" value="0" step="1" >
                        <span id="curtimetext"></span> / <span id="durtimetext"></span>
                        <button id="mutebtn" ></button>
                        <input id="volumeslider" type="range" min="0" max="100" value="100" step="1" >
                        <button id="fullscreenbtn" ></button>
                	</div>
                </div>
              </div>
    	      <div class="slide" align="center" style="background:url(imajlar/zemin.png);">
              	<img src=""  alt="aboutUs"/>
              </div>
    	      <div class="slide">
              	<object data="" height="350" width="900" type="text/html" class="islerimizSayfasi" name="islerimizSayfasi" id="islerimizSayfasi" contenteditable="true"></object>
              </div>
    	      <div class="slide">
              	<iframe src="" height="350" width="900" class="iletisimSayfasi" name="iletisimSayfasi" id="iletisimSayfasi" contenteditable="true" frameborder="0" scrolling="no"></iframe>
              </div>
            </div>
    <div id="menu">
       	   <ul id="menuButtons" class="group">
           	   <li class="menuItem" id="current_page_item_two">
                	<a href="#"></a>
                </li>
                <li  id="bosluk">
                    	<img  src="" alt="whitespace" />
                </li>
            	<li class="menuItem" id="button1">
                	<a id="hakkimizdaButon" href="">
                    	<img  src="" alt="thumbnail"  />
                    </a>
                </li>
                <li  class="bosluk2">
                  	<img src="" alt="whitespace"/>
                </li>
                
            	<li class="menuItem" id="button2">
                	<a id="islerimizButon" href="">
                    	<img  src="" alt="thumbnail" />
                    </a>
             	</li>
                <li  class="bosluk2">
                   	<img src="" alt="whitespace"/>
              	</li>
            	<li class="menuItem" id="button3">
                	<a id="iletisimButon" href="">
                    	<img src="" alt="thumbnail"/>
                    </a>
             </li>
          </ul>
    	</div>

    i'm trying to do that when i click one of menuItem buttons,the video that is playing have to be paused.
    do you have any idea for this?

  7. #7
    Join Date
    Jul 2013
    Posts
    24
    Why not link the code from your pause button to th e menu for both pause and play. That will save a lot of coding. I have to type on phone sry I can't login at work I am on a computer to read a andmd try codes.

  8. #8
    Join Date
    Apr 2013
    Posts
    44
    you mean like this:


    Code:
    var buttons;
    function addEvent(target, functionref, eventType) {
      if (target.addEventListener) {
        target.addEventListener(eventType, functionref, false);
      }
      else if (target.attachEvent) {
        target.attachEvent('on' + eventType, function() {
          return functionref.call(target, window.event)
        });
      }
    }
    function initializePlayer()
    	{
    		
    		buttons=document.getElementsByClassName("menuItem");
    	
    		addEvent(buttons,pauseVideo,"click");
    
    	}
    	window.onload=initializePlayer;
    function pauseVideo()
    		{
    			if(vid.paused){
    				vid.play();
    			}
    			else{
    				vid.pause();
    				}
    		}

  9. #9
    Join Date
    Jul 2013
    Posts
    24
    Kind of not exactly what I had in mind. I'd post if I could. But again on phone right now. Does that work I don't think it would the way you described it.

  10. #10
    Join Date
    Apr 2013
    Posts
    44
    yes i wrote that you describe but it didn't work.
    ok.
    i can wait.
    cause i couldn't find another way to do it.

Thread Information

Users Browsing this Thread

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

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.18020 seconds
  • Memory Usage 2,942KB
  • Queries Executed 15 (?)
More Information
Template Usage (33):
  • (1)SHOWTHREAD
  • (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
  • (4)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (10)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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 (72):
  • 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_postinfo_query
  • fetch_postinfo
  • 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_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