小编jal*_*bam的帖子

使内容扩展并适合PhoneGap(使用视口)

我正在尝试调整并将旧项目移植到PhoneGap.

到目前为止,该项目在Android浏览器下​​正常运行,但它不适用于PhoneGap,因为它不适应内容以适应整个屏幕.它总是留下一个空白,这不是我想要的.PhoneGap似乎没有注意我正在使用的元标记中的视口属性.

我一直在做一些测试来找出问题而没有任何结果.

例如,以下测试只包含两个文件:index.html和config.xml

它包含一个宽度为276像素的DIV,我希望PhoneGap能够像Android浏览器一样使它适合整个页面.

顺便说一句,我正在使用PhoneGap Build网站在线构建此测试.

以下是index.html文件的内容(我没有使用DOCTYPE使其更简单,但即使使用它也无法正常工作):

<html>
    <head>
        <meta name="viewport" content="width=276, user-scalable=yes" />
        <title>Title</title>
    </head>
    <body>
        <div style="width:276px; background-color:orange;">I want to make this div fit to the page</div>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

这是config.xml文件的内容(注意首选项EnableViewportScale设置为"true",但即使设置为"yes"也不起作用):

<?xml version="1.0" encoding="UTF-8" ?>
<widget xmlns = "http://www.w3.org/ns/widgets"
        xmlns:gap = "http://phonegap.com/ns/1.0"
        id        = "com.phonegap.example"
        versionCode="10" 
        version   = "1.0.0">

    <!-- versionCode is optional and Android only -->

    <name>PhoneGap Example</name>

    <description>
        An example for phonegap build docs. 
    </description>

    <author href="https://build.phonegap.com" email="support@phonegap.com">
        Hardeep Shoker 
    </author>

    <preference name="EnableViewportScale" value="true" />
</widget> …
Run Code Online (Sandbox Code Playgroud)

html css viewport metatag cordova

7
推荐指数
1
解决办法
1万
查看次数

Web Audio API和播放音频文件时的实际当前时间

当我想知道使用Web Audio API播放文件的当前时间时,我遇到了问题.我的代码很好地播放文件getCurrentTime(),当涉及快速加载的短文件时,函数返回的当前时间足够准确.

但是当我尝试加载大文件时,有时getCurrentTime()函数返回的当前时间是准确的,有时则不然.有时,等待20秒后听到文件播放,当它开始播放时,它表示当前时间约为20秒(这不是真的,因为它只是播放文件的开头).它适用于任何音频格式(OGG,MP3,WAV ......),但有时只是.

我正在使用一个慢速系统(华硕EEE PC 901与Intel Atom 1.60 Ghz和2 GB RAM与Windows XP Home Edition和SP3)和Firefox 41.0.1.

我不确定,但似乎该source.start()方法开始播放声音的方式太晚了,所以调用该方法之后的行,我设置startTime变量的值,并不是真正的开始时间.

这是代码(简化):

var context, buffer, startTime, source;
var stopped = true;
function load(file, startAt)
{
    //Here creates the AudioContext and loads the file through XHR (AJAX) and gets the buffer. All works fine.
    //When it gots the buffer through XHR (AJAX) and all is fine, it calls play(startAt) function immediately.
    //Note: normally, startAt is 0. …
Run Code Online (Sandbox Code Playgroud)

javascript html5 web-audio-api

5
推荐指数
2
解决办法
3682
查看次数

标签 统计

cordova ×1

css ×1

html ×1

html5 ×1

javascript ×1

metatag ×1

viewport ×1

web-audio-api ×1