首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >turn.js翻页时添加声音

turn.js翻页时添加声音
EN

Stack Overflow用户
提问于 2015-02-20 21:48:03
回答 4查看 2.4K关注 0票数 5

我想使用turn.js的jquery插件在翻页时添加一个声音效果。因此,第一步是根据在线文档测试执行此操作的函数。所以代码应该是这样的:

代码语言:javascript
运行
复制
    <script type="text/javascript">
    function loadApp() {

    // Create the flipbook

    $('.flipbook').turn({
            width:1000,
            height:680,
            elevation: 50,
            gradients: true,
            autoCenter: false,
    });
    $("#flipbook").bind("turned", function(event, page, view) { 
        alert("Page: "+page);
    });
    }

    yepnope({
    test : Modernizr.csstransforms,
    yep: ['../res_cod/js/turn.js'],
    nope: ['../res_cod/js/turn.html4.min.js'],
    both: ['../res_cod/css/basic.css'],
    complete: loadApp
   });
</script>

但问题是,在开发人员控制台中什么也没有发生。没有警报,什么都没有。

EN

Stack Overflow用户

发布于 2017-02-15 20:10:14

代码语言:javascript
运行
复制
function loadApp() {
//$('#audio')[0].play();
// Create the flipbook

$('.flipbook').turn({

        //when:{turning:flip.playclip()},

        // Width

        width:922,

        // Height

        height:600,

        // Elevation

        elevation: 50,

        // Enable gradients

        gradients: true,

        // Auto center this flipbook

        autoCenter: true

});
}

// Load the HTML4 version if there's not CSS transform

yepnope({
test : Modernizr.csstransforms,
yep: ['../../lib/turn.js'],
nope: ['../../lib/turn.html4.min.js'],
both: ['css/basic.css'],
complete: loadApp
});








var html5_audiotypes={ //define list of audio file extensions
"mp3": "audio/mpeg",
"ogg": "audio/ogg",
"wav": "audio/wav",
}
function createsoundbite(sound){
var html5audio=document.createElement('audio')
if (html5audio.canPlayType){ //check support for HTML5 audio
for (var i=0; i<arguments.length; i++){
var sourceel=document.createElement('source')
sourceel.setAttribute('src', arguments[i])
if (arguments[i].match(/.(\w+)$/i))
sourceel.setAttribute('type', html5_audiotypes[RegExp.$1])
html5audio.appendChild(sourceel)
}
html5audio.load()
html5audio.playclip=function(){
html5audio.pause()
html5audio.currentTime=0
html5audio.play()
}
return html5audio
}
else{
return {playclip:function(){throw new Error("Your browser doesn't support         HTML5 audio unfortunately")}}
}
}
//Initialize sound clips with 1 fallback file each:
var flip=createsoundbite("YOURSOUND.ogg", "YOURSOUND.mp3","YOURSOUND.wav")







when:{turning:flip.playclip()}; // add this line to library of turn js on         line no
299 // when left 290// not good

1218// perfect left flip     //same 1540

1407// perfect corner on hover right

1493// perfect right flip

1511// per self closing

1555// per on opening

1575 //consider



2810 only when lft mouse


  or


you can just only add audio file and play when turning with 
var vid = document.getElementById("myVideo"); 

function playVid() { 
vid.play(); 
} 

function pauseVid() { 
vid.pause(); 
}
票数 0
EN
查看全部 4 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28630499

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档