HTML5访问调用手机相机、相册功能

直接放代码(以下代码为亲测得出的结果):

    <input type="file" accept="image/*" capture="camera">安卓和IOS都为:拍照

    <input type="file" accept="video/*" capture="camcorder">安卓和IOS都为:录像

    <input type="file" accept="audio/*" capture="microphone">安卓为录音(ios视频或照片)

    <input type="file" accept="image/*">安卓为相机或照片(ios为拍照或图库2)

     <input type="file" accept="video/*">安卓为录像或视频录--(ios为录像或照片图库【照片图库已做筛选,全是视频】)

    <input type="file" accept="audio/*">安卓为录音机音乐之类的(ios为拍照或录像【包含视频和照片】)

accept 表示打开的系统文件目录;

capture( 表示的是系统所捕获的默认设备 )

         --camera:照相机;

        --camcorder:摄像机;

        --microphone:录音。

        如果不加上capture,则只会显示相应的,例如上述三种依次是:拍照或图库,录像或图库,录像或拍照或图库,加上capture之后不会调用图库。

多选( multiple )

当支持多选时,multiple优先级高于capture,所以只用写成:

<input type="file" accept="image/*" multiple>就可以。

总结:

IOS系统是不能访问录音,安卓全都可以正常访问。

发布了72 篇原创文章 · 获赞 2 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/sumjob/article/details/103587345