Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need help removing default 'mute' setting

    Hi,

    Could you please take a look at the script and tell me how to make the video preview windows opening up not muted by default. Thanks a lot for any help.

    Code:
    <!-- Template elements section -->
    
    		
    		<li class='model-menu-template' style='display: none;'><a>username</a></li>
    			
    	 	<li id='model_template' class='model' style='display: none'>
    	 	 	<div class='header'>
    				<a class='left valign' id='close_model_button' href="#"><i class="valign icon-remove-sign icon-white"></i></a>
    	 	 		<div class='left' id='username'></div>
    				<div class="dropdown right">
    					<a id="popup-menu-button" class="dropdown-toggle btn btn-mini btn-inverse" data-toggle="dropdown" href="#popup-menu">
    							Menu
    						<b class="caret"></b>
    					</a>
    					<ul class="dropdown-menu">
    						<li><a id='add_favorites_button' href="#">Add Favorites</a></li>
    						<li><a id='remove_favorites_button' href="#">Remove from Favorites</a></li>
    					</ul>
    				</div>
    				<a class='right valign' id='mute_unmute_button' href="#"><i class="valign icon-volume-off icon-white"></i></a>
    	 	 	</div>
    			<div class='content'></div>
    	 	 	<div class='footer'></div>
    	 	</li>
    
    
    		<script LANGUAGE="JavaScript" TYPE="text/javascript">				
    
    			var open_models = {};
    			
    			$('.modal').modal({show: false});
    			$('.dropdown-toggle').dropdown();
    				
    			/* Storage JSON support prototyping */
    			Storage.prototype.setObject = function(key, value) {
    				this.setItem(key, JSON.stringify(value));
    			}
    			Storage.prototype.getObject = function(key) {
    				return JSON.parse(this.getItem(key));
    			}
    			
    			/* Initialize local storage */			
    			var store = undefined;
    			function saveStore() {
    				localStorage.setObject('MFCToolsStorage', store);				
    			}
    			function clearStore() { localStorage.removeItem('MFCToolsStorage'); initStore(); }
    			function initStore() {				
    				store = localStorage.getObject('MFCToolsStorage');
    				if(store == undefined) {				
    					console.log('Initialize Local Storage');
    					store = {}
    				}
    				store.favorites = store.favorites != undefined ? store.favorites : {}; 
    				store.recent = store.recent != undefined ? store.recent : {}; 
    				store.size = store.size != undefined ? store.size : 200; 
    				store.last_session_open = store.last_session_open != undefined ? store.last_session_open : {}; 
    				store.disclaimer_acceptted = store.disclaimer_acceptted != undefined ? store.disclaimer_acceptted : false;
    				saveStore();
    			}
    			initStore();
    			
    			if(store.disclaimer_acceptted == false) {
    				$('#disclaimer_modal').modal('show');
    				
    			}
    					
    			var testing = false;
    			if(opener == undefined) {
    				console.log('Testing mode!');
    				testing = true;
    				$('#testing_menu').show();
    				$('#add_model-button').click(function(event) {
    					console.log('clicked');
    					add_model((new Date).getTime());
    					event.preventDefault();
    				});
    			}
    					
    			var video_rate = 240/320;
    			$( "#slider" ).slider({
    				value: store.size / 10,
    				min: 20,
    		 		slide: function(event, ui) {
    					var value = ui.value;
    					store.size = 10*value;
    					
    					$('embed').attr('width', store.size).attr('height', video_rate * store.size);
    					$('div.fake_content').css('min-width', store.size).css('min-height', store.size * video_rate);
    					saveStore();
    				}
    			});
    			
    			function create_add_model_menuitem(username, model_id)
    			{
    				var ret = $('.model-menu-template').clone();
    				ret.removeClass('model-menu-template');
    				ret.removeAttr('style');
    				ret.addClass('inserted_item')
    				ret.find('a').html(username)
    					.attr('id', 'add_model')
    					.attr('ref', model_id);
    				console.log(ret);
    				return ret;
    			}
    			
    			function refresh_menu(menu, list) {
    				$(menu).children('.inserted_item').remove();
    				for (var username in list)
    				{
    					var model_id = list[username];
    					var ret = create_add_model_menuitem(username, model_id);
    					$(menu).find('.insert_after').after(ret);
    				}	
    			}
    			
    			function refreshFavoritesMenu() {
    				refresh_menu('#favorites-dropdown', store.favorites);
    			}
    			function refreshRecent() {
    				refresh_menu('#recent-dropdown', store.recent);
    			}
    			refreshFavoritesMenu();
    			refreshRecent();
    			
    			$('#add_model').live('click', function(event) {
    				var model_id = $(this).attr('ref');
    				add_model(model_id);
    				console.log(model_id);
    				event.preventDefault();
    			})
    			$('#close_model_button').live('click', function(event) {
    				var main = $(this).parents('.model');
    				var model_id = main.attr('ref');
    				delete open_models[model_id];
    				main.remove();
    				event.preventDefault();
    			});
    
    			$('#mute_unmute_button').live('click', function(event) {
    				var main = $(this).parents('.model')
    				var model = open_models[main.attr('ref')];
    				var embed = main.find('embed');
    				console.log(model);
    				event.preventDefault();				
    				var mute = model.toogleMute()
    				embed.get(0).Mute(mute);
    				if($(this).find('i').length == 1)
    				{
    					$(this).find('i').removeClass('icon-volume-off')
    						.removeClass('icon-volume-up')
    						.addClass(mute ? 'icon-volume-off' : 'icon-volume-up');
    				}
    			});
    			
    			$('#add_favorites_button').live('click', function(event) {
    				event.preventDefault();
    				console.log('clicked');
    				var model_id = $(this).parents('.model').attr('ref');
    				var info = MFCInteraction.getModelInfo(model_id);
    				if(store.favorites[info.username] == undefined) {					
    					store.favorites[info.username] = model_id;
    					saveStore();
    					refreshFavoritesMenu();
    				}
    			});
    			$('#remove_favorites_button').live('click', function(event) {
    				event.preventDefault();
    				console.log('clicked');
    				var model_id = $(this).parents('.model').attr('ref');
    				var info = MFCInteraction.getModelInfo(model_id);
    				if(store.favorites[info.username] != undefined)
    				{
    					delete store.favorites[info.username];
    					saveStore();
    					refreshFavoritesMenu();
    				}
    			});
    			
    			$('#refresh_all_buttons').click(function(event) {
    				event.preventDefault();
    				$('embed').hide();
    				setTimeout(function() {
    					$('embed').show();
    					
    				}, 500);
    			});
    			
    			$('#clear_storage_button').click(function(event) {
    				event.preventDefault();
    				clearStore();
    				console.log('clear storage');
    			});
    			
    			$('#last_session_button').click(function(event) {
    				event.preventDefault();
    				console.log('clicked');
    				open_last_session();
    			});
    			
    			$('#models').sortable({
    				handle: 'div.header',
    				iframeFix: true 
    			});
    			$('#models').disableSelection({ iframeFix: true });
    			// $('#models').selectable({ iframeFix: true });
    			
    			// $( "div.button").button();
    			// $( "#organize" ).click(function(event) { 
    			// 	var top = 35
    			// 	var left = 0;
    			// 	var max_height = 0;
    			// 	var width = document.body.clientWidth;
    			// 	var height = document.body.clientHeight;
    			// 	$("div.ui-dialog-content").each(function() {
    			// 		left += this.clientWidth;
    			// 		// 
    			// 		if(left > width)
    			// 		{
    			// 			top += max_height;
    			// 			left = 0;
    			// 		}
    			// 		$(this).dialog( "option", "position", [left - this.clientWidth, top] );
    			// 
    			// 		max_height = max_height < this.clientHeight ? this.oclientHeight : max_height;
    			// 	});
    			// 	event.preventDefault();
    			// 	return false; 
    			// });		
    					
    			var MFCInteraction = {
    				info_root : (opener != undefined) ? opener.top.frames[0] : undefined,
    
    				getModelInfo : function(model_id) {
    					if(testing == false)
    						return this.info_root.g_hUsers[model_id];
    					else
    						return {
    							username : '' + model_id
    						};
    				},
    
    				getVideo : function(model_id) {
    					if(testing == false)
    						return this.info_root.DrawVideo(model_id, { 'mute': 'off' }, undefined);
    					else
    						return $('<div class="fake_content"></div>');
    				}
    			};
    				
    			function ModelPanel(model_id, win) {
    
    				var mute = true;
    				// var template = " \
    				//  	<div class='model_panel'> \
    				//  	 	<div class='header'></div> \
    				// 		<div class='content'></div> \
    				//  	 	<div class='footer'></div> \
    				//  	</div> \
    				// ";
    				console.log('model_panel');
    				if(open_models[model_id] != undefined) {
    					console.log('returning');
    					return;
    				}
    
    				var info = MFCInteraction.getModelInfo(model_id);
    				// var video = 
    				console.log(info);
    				var parent_body = $(win.document.body);
    				
    				var getContent = function() {
    					var ret = $('#model_template').clone();
    					ret.removeAttr('style');
    					ret.attr('id', 'content_' + info.user_id);
    					ret.attr('ref', info.user_id);
    					ret.find('div.content').append(MFCInteraction.getVideo(model_id));
    					ret.find('embed').attr('width', store.size).attr('height', store.size * video_rate);
    					ret.find('div.fake_content').css('min-width', store.size).css('min-height', store.size * video_rate);
    					$('div.header', ret).find('div,p').each(function() {
    						console.log($(this).attr('id'));
    						$(this).html(info[$(this).attr('id')]);
    					});
    					return ret;
    				}
    
    				var content = getContent();
    				$('#models').append(content);
    				// parent_body.append(content);
    				
    // 				$('#content_' + model_id).dialog({
    // 					width: 335,
    // 					height: 305,
    // 					close: function(event, ui) {
    // 						var model_id = $(this).attr('ref');
    // 						delete open_models[model_id];
    // 					},
    // 					resize: function(event, ui) { 
    // 						var elem = $(this);
    // 						var embed = $('embed', elem);
    // 						embed.attr('width', elem.get(0).style.width);
    // 						embed.attr('height', elem.get(0).style.height);
    // 						// embed.attr('height', $('div.model_panel', elem).css('height'));
    // 					},
    // 					buttons: {
    // 						'UnMute': function(event) {
    // 							// var value = $('span.ui-button-text', event.target).html();
    // 							// $('embed', this)[0].Mute(value == 'Mute');
    // 							// $('span.ui-button-text', event.target).html(value == 'Mute' ? 'UnMute' : 'Mute');							
    // 							// console.log('here');
    // 						},
    // 						'Profile': function() {
    // 							var model_id = $(this).attr('ref');
    // 							var info = MFCInteraction.getModelInfo(model_id);
    // 							model_id1 = "" + (100000000 + parseInt(model_id));
    // 							opener.A_Click('bio' + model_id, 'http://profiles.myfreecams.com/' + info.username, '', 't.Load(\'bio\',{user_id: \'' + model_id + '\',username: \'' + info.username + '\'},self);','new_window','bio'); 
    // 							return false;
    // 						},
    // 						'Chat': function() {
    // 							var model_id = $(this).attr('ref');							
    // 	
    // 							// var frame = $('<iframe />').attr('name', 'chat_' + model_id);
    // 							// frame.attr('width', this.style.width);
    // 							// frame.attr('height', this.style.height);
    // 							// 						 	$(this).html(frame);
    // 							// 
    // 							// $(frame).get(0).src = '/mfc2/static/player.html?broadcaster_id=' + model_id + '&target=new_window&cache_id=198','height=410,width=880,top=20,left=20,menubar=0,resizable=1,scrollbars=1,titlebar=0,toolbar=0,status=0';
    // 							// opener.t.Load('player',{broadcaster_id: model_id, target: 'chat_' + model_id}, xself);
    // 							
    // 							
    // opener.A_Click('10'+model_id,'/mfc2/static/player.html?broadcaster_id='+model_id+'&amp;target=new_window&amp;cache_id=204','height=410,width=880,top=20,left=20,menubar=0,resizable=1,scrollbars=1,titlebar=0,toolbar=0,status=0','t.Load(\'player\',{broadcaster_id: \''+model_id+'\',target: \'new_window\'},self);','new_window','player');
    // 						
    // 						},
    // 						'PM': function() {
    // 							var model_id = $(this).attr('ref');
    // opener.A_Click('register','/mfc2/php/signup.php?request=register&message=premium_feature&cache_id=204','height=480,width=800,menubar=0,resizable=1,scrollbars=1,titlebar=0,toolbar=0,status=0','t.Load(\'register\',{message: \'premium_feature\'},self);','new_window','register'); return false; 
    // 						 						 						}
    // 					}
    // 				});
    						// draggable({ iframeFix: true }).
    						// resizable({ iframeFix: true });
    				// .resizable().removeClass('dragresizable');
    				open_models[model_id] = this;
    				add_to_recent(info.username, model_id);
    				
    
    				this.toogleMute = function()
    				{	
    					mute = !mute;
    					return mute;
    				}
    				
    			}
    			
    			
    			console.log(store);
    
    			function System() {
    				console.log('MFCTools Server Loaded');
    			}
    			var system = new System();
    			
    			function add_model(model_id)
    			{
    				console.log('add_model');
    				var new_model = new ModelPanel(model_id, window);
    			}
    			function open_last_session()
    			{
    				var tmp = store.last_session_open;
    				for (var model_id in tmp)
    				{
    					var new_model = new ModelPanel(model_id, window);
    				}
    				
    			}
    			
    			function add_to_recent(username, model_id) 
    			{
    				var count = Object.keys(store.recent).length;
    				
    				console.log(count);
    				
    				count = count - 39;
    				for(var elem in store.recent) {					
    					if(count > 0)
    						delete store.recent[elem];
    					else
    						break;
    				}
    					
    				if(store.recent[username] != undefined)
    					delete store.recent[username];
    				store.recent[username] = model_id;	
    				saveStore();
    				refreshRecent();
    			}
    			
    			function HandleOnClose()
    			{
    				if(store != undefined)
    				{
    					store.last_session_open = open_models;
    					saveStore();					
    				}
    			}
    			window.add_model = add_model;
    			
    			opener.child_add_model = this.add_model;
    						
    		</script>
    	</body>
    </html>

  • #2
    Regular Coder Lerura's Avatar
    Join Date
    Aug 2005
    Location
    Denmark
    Posts
    881
    Thanks
    0
    Thanked 115 Times in 114 Posts
    The function ModelPanel contains the line:
    Code:
    var mute = true;
    Try changing it to
    Code:
    var mute = false;

  • #3
    New to the CF scene
    Join Date
    Feb 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Lerura View Post
    The function ModelPanel contains the line:
    Code:
    var mute = true;
    Try changing it to
    Code:
    var mute = false;
    Thanks for the reply.

    Yes that was the first thing I tried, didn't work.

    I also tried various other methods like completely removing the entire sections of the script containing the word 'mute' and it still didn't fix it, although strangely the script just operated normally with those sections of code removed.


  •  

    Posting Permissions

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