New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

flashvideo

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flashvideo

A UMD Web Module.

  • 1.0.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

flashvideo

a tiny library used to publish / play rtmp streams.

usage


/**
 * xdyVideo 创建Flash窗口对象
 * domEleId 界面DOM的Id
 * width 窗口对象宽度,建议100% 由容器决定
 * height 窗口对象高度,建议100% 由容器决定
 * ready_callback_function flash窗口对象创建完毕的回调函数[异步],只有该方法通知创建成功,才能向窗口对象发命令消息
 * msg_callback_function flash消息处理结果通知
 */

import xdyVideo from 'xdyVideo.js';

let publishFlash = null;
let playFlash = null;

// publish
function publishVideo() {
  const sendPublishCommand = function () {
    const msg = JSON.stringify({
      type: 10,
      data: {
        // video&audio
        video: true,
        audio: true,

        // onlyaudio
        // video: true,
        // audio: false
        url: 'rtmp://123.56.205.116:1935/live/alexwang'
      }
    });
    publishFlash._js2native(msg);
  }

  if (publishFlash) {
    return sendPublishCommand();
  }

  xdyVideo(
    'publish',
    '100%',
    '100%',
    function (error, newPublishFlash) {
      console.log(error);
      if (error) {
        return console.error(error);
      }

      // 保存Flash窗口对象,对象窗口创建不易,不要频繁创建,下次调用优先判断该对象是否存在
      publishFlash = newPublishFlash;

      sendPublishCommand();
    },
    function (msg) {
      console.log('[publish] native 2 js', msg);
    }
  )
}

// play
function playVideo() {
  const sendPlayCommand = function () {
    const msg = JSON.stringify({
      type: 2,
      data: {
        url: 'rtmp://123.56.205.116:1935/live/alexwang'
      }
    });
    playFlash._js2native(msg);
  }

  if (playFlash) {
    return sendPlayCommand();
  }

  xdyVideo(
    'play',
    '100%',
    '100%',
    function createPlayReady(error, playflash) {
      if (error) {
        return console.error(error);
      }

      // 保存Flash窗口对象,对象窗口创建不易,不要频繁创建,下次调用优先判断该对象是否存在
      playFlash = playflash;

      sendPlayCommand();
    },
    function (msg) {
      console.log(' [play] native 2 js', msg);
    }
  )
}

// 打开/关闭视频一致的
function stop() {
  const msg = JSON.stringify({
    type: 5
  });
  publishFlash._js2native(msg);
  playFlash._js2native(msg);
}

// for test purposes
publishVideo();

playVideo();

setTimeout(stop, 5000);

Keywords

FAQs

Package last updated on 17 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc