core
    正在准备搜索索引...

    接口 YmxMedia

    媒体

    interface YmxMedia {
        chooseMedia(data: ChooseMediaData): Promise<ChooseMediaResult>;
    }

    层级 (查看层级一览)

    索引

    方法

    • 拍摄或从手机相册中选择图片或视频

      参数

      返回 Promise<ChooseMediaResult>

      ymx.chooseMedia({
      // 相册
      sourceType: ['album'],
      // 选一个
      count: 1,
      mediaType: ['image'],
      }).then(res => {
      alert(JSON.stringify(res));
      });
      ymx.chooseMedia({
      // 相册
      sourceType: ['album'],
      // 选 3 个
      count: 3,
      mediaType: ['image'],
      }).then(res => {
      alert(JSON.stringify(res));
      });
      ymx.chooseMedia({
      // 拍照
      sourceType: ['camera'],
      // 后置摄像头
      camera: 'back',
      mediaType: ['image'],
      }).then(res => {
      alert(JSON.stringify(res));
      });
      ymx.chooseMedia({
      // 拍照
      sourceType: ['camera'],
      // 前置摄像头
      camera: 'front',
      mediaType: ['video'],
      }).then(res => {
      alert(JSON.stringify(res));
      });