Jump to content
Sign in to follow this  
bemben1997

(FMW41) Background Music. Ustawienie głośności Volume na starcie

Recommended Posts

Cześć mam pewien problem ze względu iż dodałem wtyczkę muzyka w profilu lecz wiadomo czasami użytkownicy mogą wgrać coś co rozwala banie no to pomyślałem żeby ustawić głośność na starcie lecz HTML5 nie posiada tego próbowałem z javascriptem coś zwalczyć lecz nie reaguje nic na to oto kod domyślny 

{{$profileSong = $member->profileSong();}}
{{if $profileSong->file and $profileSong->viewable}}
  <div class='cProfileSidebarBlock ipsPad ipsBox ipsSpacer_bottom'>
    <h2 class='ipsType_sectionHead ipsType_reset'>{lang='ps_profile_title'}</h2>
    <div class='ipsType_center'>
      <p>
        {{if \IPS\Settings::i()->song_display_autoplay}}
          <audio autoplay="" controls="" loop="" preload="" class="ps_audio">
            <source src="{$profileSong->file->url}"></source>
          </audio>
        {{else}}
          <audio controls="" loop="" preload="" class="ps_audio">
            <source src="{$profileSong->file->url}"></source>
          </audio>
        {{endif}}
      </p>
    </div>
  </div>
{{endif}}

A tutaj to co ja próbowałem zrobić 

{{$profileSong = $member->profileSong();}}
{{if $profileSong->file and $profileSong->viewable}}
  <div class='cProfileSidebarBlock ipsPad ipsBox ipsSpacer_bottom'>
    <h2 class='ipsType_sectionHead ipsType_reset'>{lang='ps_profile_title'}</h2>
    <div class='ipsType_center'>
      <p>
		<button onclick="setHalfVolume()" type="button">Set volume to 0.2</button>
        {{if \IPS\Settings::i()->song_display_autoplay}}
          <audio id="music" autoplay="" controls="" loop="" preload="" class="ps_audio">
            <source src="{$profileSong->file->url}"></source>
          </audio>
        {{else}}
          <audio id="music" controls="" loop="" preload="" class="ps_audio">
            <source src="{$profileSong->file->url}"></source>
          </audio>
<script>
var vid = document.getElementById("music");
function setHalfVolume() { 
    vid.volume = 0.2;
} 
</script> 
        {{endif}}
      </p>
    </div>
  </div>
{{endif}}

Po kliknieciu na button nic się nie dzieje  Pracuje na IPS 4.17

Share this post


Link to post

Nie powinno to być przypadkiem tak : 

<input id="volume" type="range" max="10" min="0" step="1" onchange="setVolume()" />

 

Share this post


Link to post
{{$profileSong = $member->profileSong();}}
{{if $profileSong->file and $profileSong->viewable}}
  <div class='cProfileSidebarBlock ipsPad ipsBox ipsSpacer_bottom'>
    <h2 class='ipsType_sectionHead ipsType_reset'>{lang='ps_profile_title'}</h2>
    <div class='ipsType_center'>
      <p>
        {{if \IPS\Settings::i()->song_display_autoplay}}
          <audio id="setvolume" autoplay="" controls="" loop="" preload="" class="ps_audio">
            <source src="{$profileSong->file->url}"></source>
          </audio>
        {{else}}
          <audio id="setvolume" controls="" loop="" preload="" class="ps_audio">
            <source src="{$profileSong->file->url}"></source>
          </audio>
        {{endif}}
      </p>
    </div>
  </div>
{{endif}}

 

Do oby dwóch tagów audio dodaj id="setvolume" 

 

Następnie wejdź w Wygląd - Style i szablony - Twój szablon - wpisz includeJS i tam na samym dole dodaj

{{if (\IPS\Request::i()->controller == 'profile')}}
<script> var audio = document.getElementById("setvolume"); audio.volume = 0.2; </script>
{{endif}}

 

  • Like 1

Share this post


Link to post
9 godzin temu, SeNioR napisał:

{{$profileSong = $member->profileSong();}}
{{if $profileSong->file and $profileSong->viewable}}
  <div class='cProfileSidebarBlock ipsPad ipsBox ipsSpacer_bottom'>
    <h2 class='ipsType_sectionHead ipsType_reset'>{lang='ps_profile_title'}</h2>
    <div class='ipsType_center'>
      <p>
        {{if \IPS\Settings::i()->song_display_autoplay}}
          <audio id="setvolume" autoplay="" controls="" loop="" preload="" class="ps_audio">
            <source src="{$profileSong->file->url}"></source>
          </audio>
        {{else}}
          <audio id="setvolume" controls="" loop="" preload="" class="ps_audio">
            <source src="{$profileSong->file->url}"></source>
          </audio>
        {{endif}}
      </p>
    </div>
  </div>
{{endif}}

 

Do oby dwóch tagów audio dodaj id="setvolume" 

 

Następnie wejdź w Wygląd - Style i szablony - Twój szablon - wpisz includeJS i tam na samym dole dodaj


{{if (\IPS\Request::i()->controller == 'profile')}}
<script> var audio = document.getElementById("setvolume"); audio.volume = 0.2; </script>
{{endif}}

 

Zrobiłem tak jak mówisz lecz nadal na jest na max głośność tutaj ci wstawię szablon includeJS 

{{if !\IPS\Request::i()->isAjax()}}
	<script type='text/javascript'>
		var ipsDebug = {{if ( \IPS\IN_DEV and \IPS\DEV_DEBUG_JS ) or \IPS\DEBUG_JS}}true{{else}}false{{endif}};		
	{{if \IPS\IN_DEV}}
		var CKEDITOR_BASEPATH = '{url="applications/core/dev/ckeditor" base="none" protocol="\IPS\Http\Url::PROTOCOL_RELATIVE"}/';
	{{else}}
		var CKEDITOR_BASEPATH = '{url="applications/core/interface/ckeditor/ckeditor" base="none" protocol="\IPS\Http\Url::PROTOCOL_RELATIVE"}/';
	{{endif}}
		var ipsSettings = {
			{{if \IPS\Dispatcher::hasInstance() and \IPS\Dispatcher::i()->controllerLocation == 'admin'}}
			adsess: "{expression="\IPS\Request::i()->adsess"}",
			{{endif}}
			{{if \IPS\COOKIE_DOMAIN !== NULL}}
			cookie_domain: "{expression="\IPS\COOKIE_DOMAIN"}",
			{{endif}}
			cookie_path: "{expression="\IPS\Request::getCookiePath()"}",
			{{if \IPS\COOKIE_PREFIX !== NULL}}
			cookie_prefix: "{expression="\IPS\COOKIE_PREFIX"}",
			{{endif}}
			{{if mb_substr( \IPS\Settings::i()->base_url, 0, 5 ) == 'https' AND \IPS\COOKIE_BYPASS_SSLONLY !== TRUE}}
			cookie_ssl: true,
			{{else}}
			cookie_ssl: false,
			{{endif}}
			imgURL: "{resource="./" location="front"}",
			baseURL: "{expression="\IPS\Http\Url::baseUrl( \IPS\Http\Url::PROTOCOL_RELATIVE )"}",
			jsURL: "{expression="rtrim( \IPS\Http\Url::baseUrl( \IPS\Http\Url::PROTOCOL_RELATIVE ), '/' )"}/applications/core/interface/js/js.php",
			csrfKey: "{expression="\IPS\Session::i()->csrfKey"}",
			antiCache: "{expression="\IPS\SUITE_UNIQUE_KEY"}",
			disableNotificationSounds: {{if member.members_bitoptions['disable_notification_sounds']}}true{{else}}false{{endif}},
			useCompiledFiles: {{if \IPS\IN_DEV}}false{{else}}true{{endif}},
			links_external: {setting="links_external"},
			memberID: {expression="( \IPS\Member::loggedIn()->member_id ) ? \IPS\Member::loggedIn()->member_id : 0"},
			analyticsProvider: "{expression="\IPS\Settings::i()->ipbseo_ga_provider"}",
			{{if \IPS\Settings::i()->ipbseo_ga_provider == 'custom' && \IPS\Settings::i()->ipbseo_ga_paginatecode}}
			paginateCode: function () {
				{setting="ipbseo_ga_paginatecode"}
			}
			{{endif}}
		};
	</script>
{{endif}}
{{foreach array_unique( array_filter( \IPS\Output::i()->jsFiles ), SORT_STRING ) as $js}}
{{$js = \IPS\Http\Url::external( $js );}}
<script type='text/javascript' src='{{if $js->data['host'] == parse_url( \IPS\Settings::i()->base_url, PHP_URL_HOST )}}{expression="$js->setQueryString( 'v', \IPS\SUITE_UNIQUE_KEY )"}{{else}}{expression="$js"}{{endif}}' data-ips></script>
{{endforeach}}
{{foreach array_unique( \IPS\Output::i()->jsFilesAsync, SORT_STRING ) as $js}}
<script type="text/javascript" src="{expression="\IPS\Http\Url::external( $js )->setQueryString( 'v', \IPS\SUITE_UNIQUE_KEY )"}" async="true"></script>
{{endforeach}}
{{if !\IPS\Request::i()->isAjax() and ( count( \IPS\Output::i()->jsVars ) || \IPS\Output::i()->headJs)}}
	<script type='text/javascript'>
		{{foreach \IPS\Output::i()->jsVars as $k => $v}}
			ips.setSetting( '{$k}', {{if ! is_array( $v )}}jQuery.parseJSON('{expression="json_encode( $v )" raw="true"}'){{else}}{expression="json_encode( $v )" raw="true"}{{endif}} );
		{{endforeach}}
		{expression="\IPS\Output::i()->headJs" raw="true"}
	</script>
{{endif}}
{{if (\IPS\Request::i()->controller == 'profile')}}
<script> var audio = document.getElementById("setvolume"); audio.volume = 0.2; </script>
{{endif}}

 

Share this post


Link to post

Dobra poradziłem sobie tutaj macie rozwiązanie jeśli komuś było by potrzebne 

<script>
document.getElementById("setvolume").volume = 0.2;
</script>
{{$profileSong = $member->profileSong();}}
{{if $profileSong->file and $profileSong->viewable}}
  <div class='cProfileSidebarBlock ipsPad ipsBox ipsSpacer_bottom'>
    <h2 class='ipsType_sectionHead ipsType_reset'>{lang='ps_profile_title'}</h2>
    <div class='ipsType_center'>
      <p>
        {{if \IPS\Settings::i()->song_display_autoplay}}
          <audio id="setvolume" autoplay="" controls="" loop="" preload="" class="ps_audio">
            <source src="{$profileSong->file->url}"></source>
          </audio>
        {{else}}
          <audio controls="" loop="" preload="" class="ps_audio">
            <source src="{$profileSong->file->url}"></source>
          </audio>
        {{endif}}
      </p>
    </div>
  </div>
{{endif}}

.volume = 0.2 oznacza 20% głośności na start 1.0 będzie 100%.

  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Create a New Account. It’s free and easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×
×
  • Create New...