解决方案 »

  1.   

    Android安卓移动开发 42569436
      

  2.   

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >    <FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0.39"
            android:orientation="vertical" >        <WebView
                android:id="@+id/appView"
                android:layout_width="fill_parent"
                android:layout_height="match_parent" />        <Button
                android:id="@+id/recordbutton"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:ems="10"
                android:focusableInTouchMode="true"
                android:gravity="center"
                android:keepScreenOn="true"
                android:text="按住说话"
                android:textColor="#fff"
                android:textSize="18sp" 
                android:layout_gravity="bottom"
                />    </FrameLayout></LinearLayout>
      

  3.   


    document.getElementById("recordBtn").addEventListener('click',function(e){
    e.preventDefault();
    var screenHeight = document.body.clientHeight;
    console.log(screenHeight);
    var buttonVar = "<div style='z-index: 3010;top: 397px;left: 0px;right: 0px;bottom: 0px;position: absolute;opacity: 1.3;background: #222;'><input id='lis' type='button' value='按住说话'/></div>";
    document.body.innerHTML = document.body.innerHTML + buttonVar;
    document.getElementById("lis").addEventListener('touchstart' , function(e) {
    e.preventDefault();

    console.log("start record ");

    // 开始录制音频 
            mediaRec.startRecord(); 
         
            // 10秒钟后停止录制 
            var recTime = 0; 
            var recInterval = setInterval(function() {
             recTime = recTime + 1; 
             console.log("start record "+ recTime + "sec");
                //setAudioPosition(recTime + " sec"); 
                if (recTime >= 5) {
                 console.log("end record "+ recTime + "sec");
                    clearInterval(recInterval); 
                    mediaRec.stopRecord(); 
                } 
            }, 1000);

    });
    document.getElementById("lis").addEventListener('touchmove' , function(e) {
    e.preventDefault();

    }); document.getElementById("lis").addEventListener('touchend' , function(e) {
    e.preventDefault();
    console.log("end record ");
            mediaRec.stopRecord(); 
    });
    });
      

  4.   

    appView.setOnLongClickListener(new OnLongClickListener() {

    @Override
    public boolean onLongClick(View arg0) {
    return true;
    }
    });