Skip to content

A video from the gallery ​

A video sent from a conversation's gallery picker: the conversation's openMediaPicker() opens the picker (DirectMediaPickerPhotosScreen), and the picked video's own sendVideo({ file }) reads the file's facts, sends its upload settings, encodes the video the way the server's transcode directive asks, uploads the encoded file and broadcasts video_attachment.

The video selected in the pickerA video selected in the gallery picker.

The video message in the conversationThe video message in the conversation after sendVideo({ file }).

ts
import { AndroidIgpapi, DirectMediaPickerPhotosScreen, FeedTimelineScreen } from '@igpapi/android';
import { Effect } from 'effect';
import { readFile } from 'node:fs/promises';

// A checkpoint read back from your storage (see "Keep a session").
const saved = JSON.parse(await readFile('session.json', 'utf8'));

// Send a video: the composer's "+" opens the gallery picker, and the picked video is sent.
const video = await readFile('video.mp4');
const sent = await AndroidIgpapi.launch({
  checkpoint: saved,
  screen: FeedTimelineScreen,
  main: feed =>
    Effect.gen(function* () {
      const tab = yield* feed.openDirectTab();
      const item = tab.threads[0];
      if (item === undefined) return undefined;
      const thread = yield* item.open();
      const picker = yield* thread.openMediaPicker();
      if (!DirectMediaPickerPhotosScreen.is(picker)) return undefined;
      return yield* picker.sendVideo({ file: video });
    }),
});
console.log(sent);

The file must be an MP4 with one H.264 video track, as the app's gallery offers.

The pages of this site are the README files of the repository. The API reference is generated from the source.