npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@consolecodea/react-native-mtp-camera

v0.2.7

Published

get live image from nikon or canon camera to mobile through usb

Downloads

30

Readme

react-native-mtp-camera

get live image from nikon or canon camera to mobile through usb (Android only)

npm version appveyor MIT License

Installation

npm install @consolecodea/react-native-mtp-camera

Android Setup

Permissions

To integrate react-native-mtp-camera into your Android project, follow these steps to configure your Android manifest:

  • Open Your Android Manifest File: Navigate to your Android project's android/app/src/main/AndroidManifest.xml file.
  • Add Permissions: Ensure the following permissions are included within the tag:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

These permissions are required for network communication, notifications, and running services in the foreground.

  • Declare USB Host Feature: Add the USB host feature declaration. This is essential for communicating with USB devices:
<uses-feature android:name="android.hardware.usb.host" android:required="true" />
  • Configure MainActivity: Update your tag for the MainActivity to handle USB device attachments and set launch configuration:
<activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
    android:launchMode="singleTask"
    android:windowSoftInputMode="adjustResize"
    android:exported="true">

    <!-- Main launcher intent filter -->
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>

    <!-- Intent filter for USB device attached -->
    <intent-filter>
        <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
    </intent-filter>

    <!-- Metadata for USB device filter -->
    <meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
        android:resource="@xml/device_filter" />
</activity>
  • Create a new file named device_filter.xml under android/app/src/main/res/xml/ (if it doesn't exist already), and paste the following content:
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <usb-device class="6" />
</resources>
  • Add ImageLoadingService: If your package includes a service (e.g., ImageLoadingService), declare it within the tag:
<service
    android:name="com.mtpcamera.ImageLoadingService"
    android:foregroundServiceType="dataSync" />

Explanation:

  • Permissions: Make sure to explain any critical permissions required by your package, such as INTERNET, POST_NOTIFICATIONS, and FOREGROUND_SERVICE. These are already included in your manifest.
  • Manifest Updates: Provide a clear overview of how to integrate your package into an existing Android project, highlighting key aspects like MainActivity setup, USB device attachment handling, and the ImageLoadingService.

This updated README will help users understand how to configure their Android projects to work with your react-native-mtp-camera package effectively.

Usage

import {
  startService,
  stopService,
  cameraEventLister,
  type cameraEventProps,
} from '@consolecodea/react-native-mtp-camera';
import { NativeEventEmitter } from 'react-native';
const eventEmitter = new NativeEventEmitter();

// Start the image loading service
startService()
  .then(() => {
    console.log('Service started');
  })
  .catch((error) => {
    console.error('Failed to start service:', error);
  });

// Stop the image loading service
stopService()
  .then(() => {
    console.log('Service stopped');
  })
  .catch((error) => {
    console.error('Failed to stop service:', error);
  });

// Listen for new images
  eventEmitter.addListener(
      cameraEventLister.onNewImage,
      (event: cameraEventProps) => {
        setImage(event.imagePath);
      }
    );


// Remember to remove the listener when it's no longer needed
 return () => {
      eventEmitter.removeAllListeners(cameraEventLister.onNewImage);
    };

Props

| Method | Description | | ---------------- | --------------------------------- | | startService() | Starts the image loading service. | | stopService() | Stops the image loading service. |

Event Listeners

| Listener | Description | | ------------------------------ | --------------------------------------- | | cameraEventLister.onNewImage | Triggered when a new image is received. |

Event Properties

| Property | Description | | ------------------------------ | --------------- | | cameraEventProps.imagePath | Image file uri. | | cameraEventProps.imageBase64 | Image base64. |

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT