我应该如何在Ionic 3中添加带有图像建议的相机插件,例如下面的图像

时间:2018-08-17 08:56:28

标签: ionic-framework

我添加了ionic本机摄像头插件,它工作正常。

但是我想要像whatsapp这样的相机插件。因为我想在相机插件下面的“自我”部分显示图库图片建议

enter image description here

从参考中查看上方图像。

1 个答案:

答案 0 :(得分:0)

因为没有满足您需求的本机插件,而且您正在寻找的是需要在本机插件上方编写的自定义内容。

但是许多开发人员都有这种要求。

请在下面的Github链接中找到自定义相机。

链接:https://github.com/rossmartin/cordova-plugin-instagram-assets-picker

用于库的插件方法的示例代码:

InstagramAssetsPicker.getMedia(
  function(result) { // success cb
    console.log('getMedia success, result: ', JSON.stringify(result, null, 2));
    // result will be an object with at least a phAssetId, filePath, and type property
    // you will only get the rect object when 'cropAfterSelect' is false
    // the rect object is required for the cropAsset function documented below

    /* example of result when the 'cropAfterSelect' option is set to false
    {
      phAssetId: "A1785F1A-EF0F-458C-9AF9-C439981CE0FB/L0/001",
      type: "video",
      rect: {
        Width: 0.5625000293366611,
        Height: 0.9999999823048711,
        Y: 0,
        X: 0.2496093880181434
      },
      filePath: "file:///Users/rossmartin/Library/Developer/CoreSimulator/Devices/6465544C-C262-4EA8-BA7C-8BAB4AB98597/data/Media/DCIM/100APPLE/IMG_0006.m4v"
    }
    */
  },
  function(err) { // error cb
    console.log('getMedia error, err: ', err);
  },
  { // options
    type: 'video', // accepts 'photo', 'video', or 'all' - defaults to all
    cropAfterSelect: false, // see the note above for when this is false - defaults to false
    showGrid: false // determines whether to show the grid for cropping - defaults to false
  }
);

您可以直接使用它,也可以根据需要进行fork编辑。

希望这会有所帮助。