테스트 사이트 - 개발 중인 베타 버전입니다

배경음악 넣기 질문입니다. 채택완료

닐리리맘보 3년 전 조회 3,483

https://sir.kr/g5_tip/2852

 

이것으로 배경음악 넣기는 절반만 성공했습니다.

 

pc버전은 성공했는데

모바일에는 적용이 안되네요.

소스를 head.php에 넣었습니다.

 

모바일에도 적용할 수 있는 방법이 있을까요.

아래는 head.php입니다.

 

</strong></p>

<p><strong><audio id=audioPlayer src=<a href="https://www.ramp2022.cafe24.com/audio></audio>" target="_blank" rel="noopener noreferrer">https://www.ramp2022.cafe24.com/audio></audio></a>

<script>

document.addEventListener("DOMContentLoaded", function() { audioPlayer.play(); });

</script>

  <?php

if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가</strong></p>

<p><strong>include_once(G5_THEME_PATH.'/head.sub.php');

include_once(G5_LIB_PATH.'/latest.lib.php');

include_once(G5_LIB_PATH.'/outlogin.lib.php');

include_once(G5_LIB_PATH.'/poll.lib.php');

include_once(G5_LIB_PATH.'/visit.lib.php');

include_once(G5_LIB_PATH.'/connect.lib.php');

include_once(G5_LIB_PATH.'/popular.lib.php');</strong></p>

<p><strong>?>

<audio id=audioPlayer src=<a href="https://www.ramp2022.cafe24.com/audio/song.mp3></audio>" target="_blank" rel="noopener noreferrer">https://www.ramp2022.cafe24.com/audio/song.mp3></audio></a>

<script>

document.addEventListener("DOMContentLoaded", function() { audioPlayer.play(); });

</script>

<header id="hd">

    <h1 id="hd_h1"><?php echo $g5['title'] ?></h1></strong></p>

<p><strong>    <div class="to_content"><a href="#container">본문 바로가기</a></div></strong></p>

<p><strong>    <?php

    if(defined('_INDEX_')) { // index에서만 실행

        include G5_MOBILE_PATH.'/newwin.inc.php'; // 팝업레이어

    } ?></strong></p>

<p>

<strong>    </strong></p>

<p><strong>    <div id="tnb" class="pc_view"></strong></p>

<p><strong>        <ul>

            <li class="right tnb_res"><a href=""><i class="fa fa-calendar"></i> </a></li>

            <?php echo outlogin('theme/basic'); // 외부 로그인 ?></strong></p>

<p>

<strong>        </ul>

  

    </div></strong></p>

<p>

<strong>    <div id="hd_wrapper"></strong></p>

<p><strong>        <div id="logo"><a href="<?php echo G5_URL ?>"></a></div></strong></p>

<p><strong>        <button type="button" id="gnb_open"><i class="fa fa-bars" ></i><span class="sound_only"> 메뉴열기</span></button>

        <button type="button" class="hd_sch_btn"><i class="fa fa-search"></i><span class="sound_only">검색열기</span></button></strong></p>

<p><strong>        <div id="hd_sch">

            <div class="sch_wr">

                <h2 class="sound_only">사이트 내 전체검색</h2>

                <form name="fsearchbox" action="<?php echo G5_BBS_URL ?>/search.php" onsubmit="return fsearchbox_submit(this);" method="get">

                <input type="hidden" name="sfl" value="wr_subject||wr_content">

                <input type="hidden" name="sop" value="and">

                <input type="text" name="stx" id="sch_stx" placeholder="검색어(필수)" required maxlength="20">

                <button type="submit" value="검색" id="sch_submit"><i class="fa fa-search" aria-hidden="true"></i><span class="sound_only">검색</span></button>

                </form></strong></p>

<p><strong>                <script>

                function fsearchbox_submit(f)

                {

                    if (f.stx.value.length < 2) {

                        alert("검색어는 두글자 이상 입력하십시오.");

                        f.stx.select();

                        f.stx.focus();

                        return false;

                    }</strong></p>

<p><strong>                    // 검색에 많은 부하가 걸리는 경우 이 주석을 제거하세요.

                    var cnt = 0;

                    for (var i=0; i<f.stx.value.length; i++) {

                        if (f.stx.value.charAt(i) == ' ')

                            cnt++;

                    }</strong></p>

<p><strong>                    if (cnt > 1) {

                        alert("빠른 검색을 위하여 검색어에 공백은 한개만 입력할 수 있습니다.");

                        f.stx.select();

                        f.stx.focus();

                        return false;

                    }</strong></p>

<p><strong>                    return true;

                }

                </script>

                <button type="button" class="btn_close"><i class="fa fa-times-circle"></i><span class="sound_only">검색</span></button>

            </div>

        </div></strong></p>

<p><strong>        <div id="gnb" class="pc_view">

            <ul id="gnb_1dul">

            <?php

            $menu_datas = get_menu_db(1, true);

            $i = 0;

            foreach( $menu_datas as $row ){

                if( empty($row) ) continue;

            ?>

                <li class="gnb_1dli">

                    <a href="<?php echo $row['me_link']; ?>" target="_<?php echo $row['me_target']; ?>" class="gnb_1da"><?php echo $row['me_name'] ?></a>

                    <?php

                    $k = 0;

                    foreach( (array) $row['sub'] as $row2 ){

                        if( empty($row2) ) continue;

                        if($k == 0)

                            echo '<ul class="gnb_2dul">'.PHP_EOL;

                    ?>

                        <li class="gnb_2dli"><a href="<?php echo $row2['me_link']; ?>" target="_<?php echo $row2['me_target']; ?>" class="gnb_2da"><span></span><?php echo $row2['me_name'] ?></a></li>

                    <?php

                    $k++;

                    }    //end foreach $row2</strong></p>

<p><strong>                    if($k > 0)

                        echo '</ul>'.PHP_EOL;

                    ?>

                </li>

            <?php

            $i++;

            }    //end foreach $row</strong></p>

<p><strong>            if ($i == 0) {  ?>

                <li id="gnb_empty">메뉴 준비 중입니다.<?php if ($is_admin) { ?> 
<a href="<?php echo G5_ADMIN_URL; ?>/menu_list.php">관리자모드 &gt; 환경설정 &gt; 메뉴설정</a>에서 설정하세요.<?php } ?></li>

            <?php } ?>

            </ul></strong></p>

<p><strong>        </div></strong></p>

<p><strong>        <div id="gnb2">

            <button type="button" class="btn_close"><i class="fa fa-times"></i></button>

            <ul class="gnb_tnb">

                <?php if ($is_member) {  ?></strong></p>

<p><strong>                <li><a href="<?php echo G5_BBS_URL ?>/member_confirm.php?url=<?php echo G5_BBS_URL ?>/register_form.php">정보수정</a></li>

                <li><a href="<?php echo G5_BBS_URL ?>/logout.php">로그아웃</a></li>

                <?php } else {  ?>

                <li><a href="<?php echo G5_BBS_URL ?>/register.php">회원가입</a></li>

                <li><a href="<?php echo G5_BBS_URL ?>/login.php">로그인</a></li>

                <?php }  ?></strong></p>

<p><strong>            </ul>

            <ul id="gnb2_1dul">

            <?php

            $menu_datas = get_menu_db(1, true);

            $i = 0;

            foreach( $menu_datas as $row ){

                if( empty($row) ) continue;

            ?>

                <li class="gnb2_1dli">

                    <a href="<?php echo $row['me_link']; ?>" target="_<?php echo $row['me_target']; ?>" class="gnb2_1da"><?php echo $row['me_name'] ?></a>

                    <?php

                    $k = 0;

                    foreach( (array) $row['sub'] as $row2 ){

                        if( empty($row2) ) continue;</strong></p>

<p><strong>                        if($k == 0)

                            echo '<button type="button" class="btn_gnb_op">하위분류</button><ul class="gnb2_2dul">'.PHP_EOL;

                    ?>

                        <li class="gnb2_2dli"><a href="<?php echo $row2['me_link']; ?>" target="_<?php echo $row2['me_target']; ?>" class="gnb2_2da"><span></span><?php echo $row2['me_name'] ?></a></li>

                    <?php

                    $k++;

                    }    //end foreach $row2</strong></p>

<p><strong>                    if($k > 0)

                        echo '</ul>'.PHP_EOL;

                    ?>

                </li>

            <?php

            $i++;

            }    //end foreach $row</strong></p>

<p><strong>            if ($i == 0) {  ?>

                <li id="gnb_empty">메뉴 준비 중입니다.<?php if ($is_admin) { ?> 
<a href="<?php echo G5_ADMIN_URL; ?>/menu_list.php">관리자모드 &gt; 환경설정 &gt; 메뉴설정</a>에서 설정하세요.<?php } ?></li>

            <?php } ?>

            </ul></strong></p>

<p><strong>        </div>     

        <script>

        $(function () {

            //폰트 크기 조정 위치 지정

            var font_resize_class = get_cookie("ck_font_resize_add_class");

            if( font_resize_class == 'ts_up' ){

                $("#text_size button").removeClass("select");

                $("#size_def").addClass("select");

            } else if (font_resize_class == 'ts_up2') {

                $("#text_size button").removeClass("select");

                $("#size_up").addClass("select");

            }</strong></p>

<p><strong>            $(".hd_opener").on("click", function() {

                var $this = $(this);

                var $hd_layer = $this.next(".hd_div");</strong></p>

<p><strong>                if($hd_layer.is(":visible")) {

                    $hd_layer.hide();

                    $this.find("span").text("열기");

                } else {

                    var $hd_layer2 = $(".hd_div:visible");

                    $hd_layer2.prev(".hd_opener").find("span").text("열기");

                    $hd_layer2.hide();</strong></p>

<p><strong>                    $hd_layer.show();

                    $this.find("span").text("닫기");

                }

            });</strong></p>

<p>

<strong>            $(".btn_gnb_op").click(function(){

                $(this).toggleClass("btn_gnb_cl").next(".gnb2_2dul").slideToggle(300);

                

            });</strong></p>

<p><strong>            $(".hd_closer").on("click", function() {

                var idx = $(".hd_closer").index($(this));

                $(".hd_div:visible").hide();

                $(".hd_opener:eq("+idx+")").find("span").text("열기");

            });</strong></p>

<p><strong>            $(".hd_sch_btn").on("click", function() {

                $("#hd_sch").show();

            });</strong></p>

<p><strong>            $("#hd_sch .btn_close").on("click", function() {

                $("#hd_sch").hide();

            });</strong></p>

<p><strong>            

            $("#gnb_open").on("click", function() {

                $("#gnb2").show();

            });</strong></p>

<p><strong>            $("#gnb2 .btn_close").on("click", function() {

                $("#gnb2").hide();

            });</strong></p>

<p><strong> 

        });</strong></p>

<p><strong>        //상단고정

        if( $("#hd").length ){

            var jbOffset = $("#hd").offset();

            $( window ).scroll( function() {

                if ( $( document ).scrollTop() > jbOffset.top ) {

                    $( 'body' ).addClass( 'fixed' );

                }

                else {

                    $( 'body' ).removeClass( 'fixed' );

                }

            });

        }

        </script>

        

    </div>

   <!-- SCM Music Player <a href="https://www.scmplayer.net" target="_blank" rel="noopener noreferrer">https://www.scmplayer.net</a> -->

<script type="text/javascript" src="<a href="https://www.scmplayer.net/script.js" " target="_blank" rel="noopener noreferrer">https://www.scmplayer.net/script.js" </a>

data-config="{'skin':'skins/simpleBlack/skin.css','volume':50,'autoplay':false,'shuffle':false,'repeat':1,'placement':'top','showplaylist':false,'playlist':[{'title':'%uC81C%uC8FC%uC758%uB178%uB798','url':'<a href="http://ramp2022.cafe24.com/audio/song.mp3'}]}"" target="_blank" rel="noopener noreferrer">http://ramp2022.cafe24.com/audio/song.mp3'}]}"</a> ></script>

<!-- SCM Music Player script end -->

</header></strong></p>

<p><strong><div id="wrapper"></strong></p>

<p><strong>    <div id="container">

    <?php if (!defined("_INDEX_")) { ?><h2 id="container_title" class="top" title="<?php echo get_text($g5['title']); ?>"><?php echo get_head_title($g5['title']); ?></h2><?php } ?></strong></p>

<p><strong>

댓글을 작성하려면 로그인이 필요합니다.

답변 2개

채택된 답변
+20 포인트
3년 전

모바일은 오토플레이하면 자동 음소거가 됩니다.

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

닐리리맘보
3년 전
수동으로 바껴도 좋은데 플레이어 버튼이 안 나와요.;;;;
pc에서는 버튼이 잘 나왔거든요

댓글을 작성하려면 로그인이 필요합니다.

케빈엉클
10개월 전

이렇게도 함 해보세요..

 

<audio id="music" src="../files/sample.mp3" autoplay loop></audio>

<?php }?>

    <!--위에 음악 15초만 들려주기 

<script>

    (function( d ) {

       'use strict';

   

       var p = d.getElementById('music'),

           playtime = 15; /* adjust this value to suit */

   

       p.addEventListener( 'timeupdate',

          function() {

             if (  Math.floor( p.currentTime ) === playtime ) {

                   p.pause();

                   p.currentTime += 1;

               }

        },false );

    }( document ));

    </script>

    -->

 

참고자료

https://sir.kr/g5_skin/60750">https://sir.kr/g5_skin/60750

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인