### Start Node.js Project Source: https://www.nodemedia.cn/document?document=143&project=11 Use this command to start your Node.js project. Ensure you have npm installed. ```bash 1. npm start ``` -------------------------------- ### Quick Start: Initialize and Start Streaming Source: https://www.nodemedia.cn/document?document=147&project=4 Initialize NodePublisher, set audio/video parameters, open the camera, attach a preview view, and start the RTMP stream. ```objective-c // Initialize the streamer NodePublisher *pub = [[NodePublisher alloc] initWithLicense:@"your-license"]; // Set audio and video encoding parameters [pub setVideoParamWithCodec:NMC_CODEC_ID_H264 profile:NMC_PROFILE_H264_MAIN width:720 height:1280 fps:24 bitrate:1200 * 1000]; [pub setAudioParamWithCodec:NMC_CODEC_ID_AAC profile:NMC_PROFILE_AAC_LC samplerate:44100 channels:1 bitrate:64 * 1000]; // Open the front camera [pub openCamera:YES]; // Attach preview view [pub attachView:self.previewView]; // Start streaming [pub start:@"rtmp://live.example.com/publish/streamKey"]; ``` -------------------------------- ### Install NodeMedia Engine as a System Service on Linux Source: https://www.nodemedia.cn/document?document=19&project=2 Installs the NodeMedia Engine as a system service on Linux after decompression. Navigate to the program directory and execute the install command. ```bash ./service.sh install ``` -------------------------------- ### Install Pods Source: https://www.nodemedia.cn/document?document=112&project=4 Install the pods defined in your Podfile. This command downloads and integrates the specified libraries into your project. ```bash pod install ``` -------------------------------- ### Start Streaming Action Source: https://www.nodemedia.cn/document?document=109&project=4 Initiates the live stream when the start button is pressed, using the provided URL. ```objectivec - (IBAction)startAction:(id)sender { [_np start:self.urlField.text]; } ``` -------------------------------- ### Initialize and Start NodePlayer Instance Source: https://www.nodemedia.cn/document?document=126&project=6 Initialize the application instance, create a window, and then create, attach, and start the NodePlayer instance with a given stream URL. Ensure the NodePlayer_attachView function is called with a valid window handle. ```cpp BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { hInst = hInstance; // 将实例句柄存储在全局变量中 HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr); if (!hWnd) { return FALSE; } ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); np = NodePlayer_new("", ""); NodePlayer_attachView(np,hWnd); NodePlayer_start(np,"rtmp://192.168.0.2/live/bbb"); return TRUE; } ``` -------------------------------- ### Install NodeMedia Engine on Linux x86_64 Source: https://www.nodemedia.cn/document?document=19&project=2 Installs the NodeMedia Engine on a Linux x86_64 system using a single command. This involves downloading the archive, extracting it, and running the installation script. ```bash curl -L https://cdn.nodemedia.cn/nme/1.2.0/nme-linux-amd64-v1.2.0-20260527.tar.gz | tar xz;cd nme-linux-amd64;./service.sh install ``` -------------------------------- ### Initialize and Start NodePlayer Source: https://www.nodemedia.cn/document?document=146&project=4 Initializes the NodePlayer with a license, attaches a rendering view, and starts playback from a given stream URL. ```objective-c 1. // 初始化播放器 2. NodePlayer *player = [[NodePlayer alloc] initWithLicense:@"your-license"]; 3. 4. // 附加渲染视图 5. [player attachView:self.renderView]; 6. 7. // 开始播放 8. [player start:@"rtmp://example.com/live/stream"]; ``` -------------------------------- ### Initialize NodePlayer with Controller and Start Playback Source: https://www.nodemedia.cn/document?document=148&project=8 Demonstrates how to initialize the NodePlayer component with a controller, set the media source, and then programmatically start playback. ```typescript let playerController = new NodePlayerController(); NodePlayer({ controller: playerController, src: 'rtsp://example.com/stream' }); playerController.start(); ``` -------------------------------- ### Install NodeMedia Server as a Service in Linux Source: https://www.nodemedia.cn/document?document=106&project=3 This command downloads, extracts, and installs the NodeMedia Server as a service on a Linux system. Ensure you are in the desired directory before execution. ```bash curl -L https://cdn.nodemedia.cn/nms/3.26.4/nms-linux-amd64-v3.26.4-20260427.tar.gz | tar xz;cd nms-linux-amd64;./service.sh install ``` -------------------------------- ### Start Playback Action Source: https://www.nodemedia.cn/document?document=108&project=4 Implement the action for the start button to initiate playback using the URL from the text field. ```objectivec - (IBAction)startAction:(id)sender { [_np start:self.urlField.text]; } ``` -------------------------------- ### Install NodePlayer Addon Source: https://www.nodemedia.cn/document?document=137&project=11 Install the nodeplayer-addon package using npm. ```bash npm i nodeplayer-addon ``` -------------------------------- ### Initialize Podfile Source: https://www.nodemedia.cn/document?document=112&project=4 Create a Podfile in your project directory if it does not exist. This is the first step for Cocoapods installation. ```bash pod init ``` -------------------------------- ### NodePlayer Initialization and Playback Source: https://www.nodemedia.cn/document?document=146&project=4 Demonstrates how to initialize the NodePlayer, attach a rendering view, and start playing a media stream. ```APIDOC ## NodePlayer Initialization and Playback ### Description Initializes the NodePlayer with a license, attaches a rendering view, and starts playback of a specified media stream URL. ### Method Initialization and playback are typically handled by calling methods on the `NodePlayer` class. ### Endpoint N/A (SDK method calls) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```objective-c // Initialize the player NodePlayer *player = [[NodePlayer alloc] initWithLicense:@"your-license"]; // Attach rendering view [player attachView:self.renderView]; // Start playback [player start:@"rtmp://example.com/live/stream"]; ``` ### Response #### Success Response Playback starts successfully. #### Response Example N/A (SDK method calls) ``` -------------------------------- ### start(url) Source: https://www.nodemedia.cn/document?document=135&project=10 Initiates the streaming process to the specified WebSocket-FLV push stream URL. ```APIDOC ## start(url) ### Description Starts the streaming process. ### Parameters #### Path Parameters - **url** (string) - Required - The URL for the websocket-flv push stream. ``` -------------------------------- ### Install node-static dependency Source: https://www.nodemedia.cn/document?document=15&project=1 This command installs the 'node-static' package, which is used to create a static file service. ```bash npm i node-static ``` -------------------------------- ### Install Ant Design Source: https://www.nodemedia.cn/document?document=143&project=11 Install the Ant Design library into your project using npm. ```bash 1. npm install antd ``` -------------------------------- ### Start Video Playback Source: https://www.nodemedia.cn/document?document=13&project=1 Initiate video playback by calling the start method with the stream URL when the game begins. ```typescript onTipClick(e: Laya.Event): void { this.tipLbll.visible = false; this._score = 0; this.scoreLbl.text = ""; this._control.startGame(); //开始播放流 this._player.start("http://flv.bdplay.nodemedia.cn/live/bbb.flv"); } ``` -------------------------------- ### Complete Live Push Example in Objective-C Source: https://www.nodemedia.cn/document?document=147&project=4 This snippet shows a full implementation of a live push view controller using NodeMediaClient. It covers initialization, parameter configuration, camera preview, and stream control. ```Objective-C #import @interface LivePushViewController () @property (nonatomic, strong) NodePublisher *publisher; @property (nonatomic, strong) UIView *previewView; @end @implementation LivePushViewController - (void)viewDidLoad { [super viewDidLoad]; // Initialize self.publisher = [[NodePublisher alloc] initWithLicense:@"your-license"]; self.publisher.nodePublisherDelegate = self; self.publisher.logLevel = 1; // Configure encoding parameters [self.publisher setVideoParamWithCodec:NMC_CODEC_ID_H264 profile:NMC_PROFILE_H264_MAIN width:720 height:1280 fps:24 bitrate:1200000]; [self.publisher setAudioParamWithCodec:NMC_CODEC_ID_AAC profile:NMC_PROFILE_AAC_LC samplerate:44100 channels:1 bitrate:64000]; // Enable hardware encoding & denoise self.publisher.HWAccelEnable = YES; self.publisher.denoiseEnable = YES; self.publisher.keyFrameInterval = 2; // Beauty effects [self.publisher setEffectStyleWithId:EFFECTOR_STYLE_ID_ENHANCED]; [self.publisher setEffectParameter:EFFECTOR_SMOOTHSKIN withIntensity:0.5]; // Open camera and preview [self.publisher openCamera:YES]; [self.publisher attachView:self.previewView]; } - (IBAction)didTapStart:(id)sender { [self.publisher start:@"rtmp://live.example.com/publish/streamKey"]; } - (IBAction)didTapStop:(id)sender { [self.publisher stop]; } - (IBAction)didTapSwitchCamera:(id)sender { [self.publisher switchCamera]; } - (IBAction)didTapTorch:(id)sender { self.publisher.torchEnable = !self.publisher.torchEnable; } - (void)onEventCallback:(id)sender event:(int)event msg:(NSString *)msg { switch (event) { case 2: NSLog(@"Push stream connected"); break; case 11: NSLog(@"Push stream error: %@", msg); break; default: break; } } - (void)dealloc { [self.publisher stop]; [self.publisher closeCamera]; [self.publisher detachView]; } @end ``` -------------------------------- ### Example FFplay URL with Parameters Source: https://www.nodemedia.cn/document?document=40&project=3 Demonstrates how to include URL parameters when playing an RTMP stream with ffplay. ```bash ffplay "rtmp://localhost/live/stream?user=123&vip=0&money=666&time=50" ``` -------------------------------- ### Start Playback Action Source: https://www.nodemedia.cn/document?document=107&project=4 This action is triggered when the start button is pressed. It initiates playback using the URL entered in the text field. Ensure the URL field is not empty. ```swift @IBAction func startAction(_ sender: Any) { np.start(urlField.text!) } ``` -------------------------------- ### start: Source: https://www.nodemedia.cn/document?document=146&project=4 Starts playing the media stream from the specified URL. Returns a status code (0 for success, non-zero for failure). Supports rtmp, rtsp, http, and https protocols. ```APIDOC ## start: ### Description Start playing the media stream from the specified URL. Returns a status code (`0` indicates success, non-`0` indicates failure). Supported protocols: `rtmp://` , `rtsp://`, `http://`,`https://`. ### Method - (NSInteger)start:(NSString *)url ### Parameters #### Path Parameters - **url** (NSString *) - Media stream URL address ### Return Value - **NSInteger** - Status code (`0` indicates success, non-`0` indicates failure) ### Request Example ```objective-c NSInteger ret = [player start:@"rtmp://live.example.com/stream"]; if (ret != 0) { NSLog(@"启动播放失败: %ld", (long)ret); } ``` ``` -------------------------------- ### startRecord: Source: https://www.nodemedia.cn/document?document=146&project=4 Starts recording the currently playing media stream to a file at the specified path. Returns a status code. ```APIDOC ## startRecord: ### Description Start recording the currently playing media stream to a file at the specified path. Returns a status code. ### Method - (NSInteger)startRecord:(NSString *)filename; ### Parameters #### Path Parameters - **filename** (NSString *) - Recorded output file path ### Return Value - **NSInteger** - Status code ### Request Example ```objective-c NSString *path = [NSTemporaryDirectory() stringByAppendingPathComponent:@"recorded.mp4"]; [player startRecord:path]; ``` ``` -------------------------------- ### Start Video Playback on Button Click Source: https://www.nodemedia.cn/document?document=12&project=1 Initiate video playback by calling the start method with the video stream URL in response to a button click event. ```typescript this.player.start("http://flv.bdplay.nodemedia.cn/live/bbb.flv"); ``` -------------------------------- ### Start Camera Streaming Source: https://www.nodemedia.cn/document?document=134&project=10 Initiate the camera streaming process using the NodePublisher instance. Provide the URL where the stream will be sent. ```javascript nodePublisher.start(url); ``` -------------------------------- ### Initialize and control NodePlayer in mainwindow.cpp Source: https://www.nodemedia.cn/document?document=125&project=6 Initialize NodePlayer, attach it to the window, set scale mode, and start playback in the main window's constructor and destructor. ```cpp #include "mainwindow.h" #include "./ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); np = NodePlayer_new("",""); NodePlayer_setScaleMode(np,1); NodePlayer_attachView(np,(HWND)this->winId()); NodePlayer_start(np,"rtmp://192.168.0.2/live/bbb"); } MainWindow::~MainWindow() { NodePlayer_detachView(np); NodePlayer_stop(np); NodePlayer_free(np); delete ui; } ``` -------------------------------- ### NodePlayer_start Source: https://www.nodemedia.cn/document?document=119&project=6 Starts playing the stream from the given URL. ```APIDOC ## NodePlayer_start ### Description Start playing. ### Signature `int NodePlayer_start(NodePlayer _ctx, const char_ url)` ### Parameters * **_ctx** (NodePlayer) - Required - The player context. * **url** (const char_) - Required - The URL of the stream to play. ``` -------------------------------- ### NodePublisher_start Source: https://www.nodemedia.cn/document?document=121&project=6 Starts the live streaming process to the specified URL. This function initiates the transmission of audio and video data. ```APIDOC ## NodePublisher_start ### Description Starts streaming to the specified URL. ### Method int NodePublisher_start(NodePublisher *ctx, const char* url); ### Parameters * **ctx** (NodePublisher *) - Pointer to the NodePublisher instance. * **url** (const char*) - The URL of the streaming server. ``` -------------------------------- ### Initialize and Play Video in Activity Source: https://www.nodemedia.cn/document?document=117&project=5 Initialize NodePlayer in your Activity, set up event listeners, attach the view, and start playback with a given URL. ```java package cn.nodemedia.javademo; import android.os.Bundle; import android.util.Log; import android.widget.FrameLayout; import androidx.appcompat.app.AppCompatActivity; import cn.nodemedia.NodePlayer; public class LivePlayerActivity extends AppCompatActivity { private NodePlayer np; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_live_player); FrameLayout vv = findViewById(R.id.videoView); np = new NodePlayer(this, ""); np.setOnNodePlayerEventListener((player, event, msg) -> { Log.d("NodePlayer", "event:" + event + " msg:" + msg); }); // 设置事件监听器 np.attachView(vv); // 附加到视图 np.setBufferTime(1000); // 设置缓冲时间 单位 ms, 可随时修改 np.setScaleMode(1); // 设置缩放模式 可随时修改 np.setVolume(1.0f);// 设置音量, 可随时修改 np.setHWAccelEnable(true); // 启用硬件加速 // np.setRTSPTransport("tcp");// 设置 RTSP 传输模式 // np.setHTTPReferer("custom http referer"); // np.setHTTPUserAgent("custom http user agent"); np.start("rtmp://live.nodemedia.cn/live/bbb"); // 开始播放 } @Override protected void onDestroy() { super.onDestroy(); np.stop(); // 停止播放 np.detachView(); // 移除视图 } } ``` -------------------------------- ### Include NodePlayer Header and Initialize Player Source: https://www.nodemedia.cn/document?document=126&project=6 Include the NodePlayer header file and declare global variables for the application instance and the NodePlayer instance. This is the initial setup required before using the NodePlayer API. ```cpp #include "NodePlayer.h" #define MAX_LOADSTRING 100 // 全局变量: HINSTANCE hInst; // 当前实例 WCHAR szTitle[MAX_LOADSTRING]; // 标题栏文本 WCHAR szWindowClass[MAX_LOADSTRING]; // 主窗口类名 NodePlayer* np; //播放器实例 ``` -------------------------------- ### HTML Video Tag Setup Source: https://www.nodemedia.cn/document?document=134&project=10 Prepare an HTML video tag for displaying the camera feed. Ensure it has an ID for JavaScript reference and is set to autoplay and muted. ```html ``` -------------------------------- ### Start Recording Media Stream Source: https://www.nodemedia.cn/document?document=146&project=4 Begins recording the currently playing media stream to a specified file. Returns a status code. ```objective-c 1. - (NSInteger)startRecord:(NSString *)filename; ``` ```objective-c 1. NSString *path = [NSTemporaryDirectory() stringByAppendingPathComponent:@"recorded.mp4"]; 2. [player startRecord:path]; ``` -------------------------------- ### Using NodePlayer.js media player Source: https://www.nodemedia.cn/document?document=15&project=1 This script demonstrates how to initialize and use the NodePlayer.js component within an HTML page. It loads the player, sets the video view, and starts streaming from a specified URL. ```html ``` -------------------------------- ### Initialize and Configure NodePublisher Source: https://www.nodemedia.cn/document?document=134&project=10 Load the NodePublisher library and initialize a new instance. Set the audio and video sources, and configure encoding parameters for both audio and video streams. ```javascript var nodePublisher; NodePublisher.load(async () => { nodePublisher = new NodePublisher(); nodePublisher.setAudioSource(); nodePublisher.setVideoSource("video"); nodePublisher.setAudioConfig("mp4a.40.2", 96000, 1, 48000); nodePublisher.setVideoConfig("avc1.64001E", 1920, 1080, 30, 60, 2000000); }) ``` -------------------------------- ### Complete NodeMediaClient Objective-C Example Source: https://www.nodemedia.cn/document?document=146&project=4 This snippet shows the full implementation of a view controller using NodeMediaClient for video playback. It covers initialization, configuration, event handling, and playback control. Ensure you have a valid license key and a UIView for rendering. ```Objective-C #import @interface MyViewController () @property (nonatomic, strong) NodePlayer *player; @property (nonatomic, strong) UIView *videoView; @end @implementation MyViewController - (void)viewDidLoad { [super viewDidLoad]; // Initialize player self.player = [[NodePlayer alloc] initWithLicense:@"your-license"]; self.player.nodePlayerDelegate = self; // Configuration self.player.bufferTime = 1500; // 1.5 seconds buffer self.player.scaleMode = 1; // Aspect ratio scaling self.player.HWAccelEnable = YES; // Hardware decoding enabled self.player.logLevel = 1; // Info level logs // Attach rendering view [self.player attachView:self.videoView]; // Start playback [self.player start:@"rtmp://live.example.com/stream"]; } - (void)onEventCallback:(id)sender event:(int)event msg:(NSString *)msg { switch (event) { case 2: NSLog(@"Connection successful"); break; case 4: NSLog(@"Buffer finished, starting playback"); break; case 11: NSLog(@"Playback error: %@", msg); break; default: break; } } - (IBAction)didTapPause:(id)sender { [self.player pause:YES]; } - (IBAction)didTapResume:(id)sender { [self.player pause:NO]; } - (IBAction)didTapStop:(id)sender { [self.player stop]; } - (void)dealloc { [self.player detachView]; [self.player stop]; } @end ``` -------------------------------- ### initWithLicense: Source: https://www.nodemedia.cn/document?document=146&project=4 Initializes the player using a provided license key. Returns an initialized NodePlayer instance. ```APIDOC ## initWithLicense: ### Description Initialize the player using the license. Returns an initialized `NodePlayer` instance. ### Method - (instancetype)initWithLicense:(NSString *)license ### Parameters #### Path Parameters - **license** (NSString *) - NodePlayer license string ### Request Example ```objective-c NodePlayer *player = [[NodePlayer alloc] initWithLicense:@"your-license-key"]; ``` ``` -------------------------------- ### Start Media Playback Source: https://www.nodemedia.cn/document?document=146&project=4 Starts playing a media stream from the specified URL. Supports RTMP, RTSP, HTTP, and HTTPS protocols. Returns a status code indicating success or failure. ```objective-c 1. - (NSInteger)start:(NSString *)url; ``` ```objective-c 1. NSInteger ret = [player start:@"rtmp://live.example.com/stream"]; 2. if (ret != 0) { 3. NSLog(@"启动播放失败: %ld", (long)ret); 4. } ``` -------------------------------- ### Open Camera for Preview Source: https://www.nodemedia.cn/document?document=109&project=4 Initiates the camera to provide a preview of the video feed. ```objectivec [_np openCamera:YES]; ``` -------------------------------- ### Control Playback Start and Stop Source: https://www.nodemedia.cn/document?document=122&project=6 Handles the logic for starting and stopping video playback. It also manages the button text to reflect the current playback state and ensures the playback object is freed when the form closes. ```csharp private void button1_Click(object sender, EventArgs e) { if(_isStarting) { _NodePlayer_stop(_npHandle); button1.Text = "Start"; } else { var windowId = pictureBox1.Handle; _NodePlayer_attachView(_npHandle, windowId); _NodePlayer_setScaleMode(_npHandle,1); _NodePlayer_setBufferTime(_npHandle, 500); _NodePlayer_start(_npHandle, GetUtf8Bytes(textBox1.Text)); button1.Text = "Stop"; } _isStarting = !_isStarting; } private void Form1_FormClosing(object sender, FormClosingEventArgs e) { if (_npHandle != IntPtr.Zero) { _NodePlayer_free(_npHandle); } } ``` -------------------------------- ### Initialize NodePlayer and Attach Video View Source: https://www.nodemedia.cn/document?document=107&project=4 Initializes the NodePlayer with a license and attaches it to a specified video view. Ensure you have a valid license string. ```swift import UIKit import NodeMediaClient class ViewController: UIViewController { @IBOutlet weak var videoView: UIView! @IBOutlet weak var urlField: UITextField! var np: NodePlayer! override func viewDidLoad() { super.viewDidLoad() np = NodePlayer.init(license: "your license string") np.attach(videoView) } } ``` -------------------------------- ### Stream Control Source: https://www.nodemedia.cn/document?document=145&project=5 Methods for starting and stopping the media stream. ```APIDOC ## `int start(String url)` ### Description Start streaming. ### Parameters #### Path Parameters * **url** (String) - Required - Push stream address, such as `rtmp://example.com/live/stream`. ### Return * **int** - Operation result (0 for success, non-zero for failure). ``` ```APIDOC ## `int stop()` ### Description Stop streaming. ### Return * **int** - Operation result. ``` -------------------------------- ### bufferPosition Source: https://www.nodemedia.cn/document?document=146&project=4 Gets the current video buffering progress in milliseconds. This is a read-only property. ```APIDOC ## bufferPosition ### Description Current video buffering progress, in milliseconds. This is a read-only property. ### Property - **bufferPosition** (NSInteger) - Read-only ``` -------------------------------- ### currentPosition Source: https://www.nodemedia.cn/document?document=146&project=4 Gets the current video playback progress in milliseconds. This is a read-only property. ```APIDOC ## currentPosition ### Description Current video playback progress, in milliseconds. This is a read-only property. ### Property - **currentPosition** (NSInteger) - Read-only ``` -------------------------------- ### PostRecord Event Data Source: https://www.nodemedia.cn/document?document=40&project=3 Data received when NMS starts recording an RTMP stream. ```json { id: 'a2z6rdsndjjlovfknt0ovqtpigwz35rp', ip: '192.168.0.6:65459', mid: '4557d7a8031ae338275aab5f4ed03d184e8217cf8c4e8ab2bdf1a14184b9003d', app: 'live', name: 'bbb1', query: {}, action: 'postRecord', protocol: 'rtmp', createtime: 1687080346427, endtime: 0, inbytes: 0, outbytes: 0, filename: '2023-06-18/17-25-46.mp4' } ``` -------------------------------- ### Create Electron App Source: https://www.nodemedia.cn/document?document=137&project=11 Use npx to create a new Electron application with default settings. ```bash npx create-electron-app@latest my-app ``` -------------------------------- ### Start NodePlayer Playback Source: https://www.nodemedia.cn/document?document=2&project=1 Initiates video playback by providing the stream URL to the player. ```javascript player.start("http://pull.yourdomain.com/live/stream.flv"); ``` -------------------------------- ### Create and Configure NodePlayer Instance Source: https://www.nodemedia.cn/document?document=13&project=1 Instantiate the NodePlayer object, set the video view, and configure buffer time during the game's enable event. ```typescript onEnable(): void { this._control = this.getComponent(GameControl); //点击提示文字,开始游戏 this.tipLbll.on(Laya.Event.CLICK, this, this.onTipClick); //创建播放器 this._player = new NodePlayer(); this._player.setView("video"); this._player.setBufferTime(500); } ``` -------------------------------- ### Recording Source: https://www.nodemedia.cn/document?document=144&project=5 Methods to start and stop recording the currently playing audio and video stream to a file. ```APIDOC ## Recording ### `int startRecord(String filename)` Start recording the currently playing audio and video stream. #### Parameters - **filename** (`String`) - Required - Record filenames, supporting `.mp4`, `.flv`, `.mkv`, and `.ts` formats. **Return:** `int` - Operation result. ### `int stopRecord()` Stop recording. **Return:** `int` - Operation result. ``` -------------------------------- ### Initialize NodePlayer with License Source: https://www.nodemedia.cn/document?document=146&project=4 Initializes the player instance using a provided license key. This is a required step before using other player functionalities. ```objective-c 1. - (instancetype)initWithLicense:(NSString *)license; ``` ```objective-c 1. NodePlayer *player = [[NodePlayer alloc] initWithLicense:@"your-license-key"]; ``` -------------------------------- ### Get Current Buffer Position Source: https://www.nodemedia.cn/document?document=146&project=4 Read-only property indicating the current buffering progress in milliseconds. ```objective-c 1. @property (nonatomic, readonly) NSInteger bufferPosition; ``` -------------------------------- ### Initialize NodePlayer with Advanced Settings Source: https://www.nodemedia.cn/document?document=107&project=4 This Swift code initializes the NodePlayer with a license key and configures advanced settings such as hardware acceleration, scale mode, and buffer time. It then attaches the player to a video view. ```swift override func viewDidLoad() { super.viewDidLoad() np = NodePlayer.init(license: "your license string") np.hwAccelEnable = true np.scaleMode = 1 np.bufferTime = 100 np.attach(videoView) } ``` -------------------------------- ### Get Current Playback Position Source: https://www.nodemedia.cn/document?document=146&project=4 Read-only property indicating the current playback progress in milliseconds. ```objective-c 1. @property (nonatomic, readonly) NSInteger currentPosition; ``` -------------------------------- ### Successful Relay Task Deletion Response Source: https://www.nodemedia.cn/document?document=76&project=3 Example of a successful response when deleting a relay task. ```JSON { "code": 200, "error": "", "data": null } ``` -------------------------------- ### Link libNodeMediaClient library in CMakeLists.txt Source: https://www.nodemedia.cn/document?document=125&project=6 Link the libNodeMediaClient library to your Qt project's target. ```cmake # 添加 libNodeMediaClient target_link_libraries(NodePlayer-qt PRIVATE Qt${QT_VERSION_MAJOR}::Widgets libNodeMediaClient) ``` -------------------------------- ### Relay Task Not Found Response Source: https://www.nodemedia.cn/document?document=76&project=3 Example of an error response when the specified relay task ID is not found. ```JSON { "code": 404, "error": "Not Found", "data": null } ``` -------------------------------- ### Create Electron Project with React Source: https://www.nodemedia.cn/document?document=138&project=11 Use the npm create command to scaffold a new Electron project. This command prompts for project name, framework (React), TypeScript usage, and Electron updater plugin. ```bash npm create @quick-start/electron ``` ```bash npx > "create-electron" Project name: … electron-app-react Select a framework: › react Add TypeScript? … No / Yes Add Electron updater plugin? … No / Yes Enable Electron download mirror proxy? … No / Yes Scaffolding project in electron-app-react... Done. Now run: cd electron-app-react npm install npm run dev ``` -------------------------------- ### PostPlay Event Data Source: https://www.nodemedia.cn/document?document=40&project=3 Data received by the web server when a user starts playing an RTMP stream from NMS. ```json { id: 'xs503tuy3e1fpr4g80j3xbak3z1zay6o', ip: '[::1]:60132', app: 'live', name: 'stream', query: {}, action: 'postPlay', protocol: 'rtmp', createtime: 1575452825248, endtime: 0, inbytes: 0, outbytes: 0 } ``` -------------------------------- ### PostPublish Event Data Source: https://www.nodemedia.cn/document?document=40&project=3 Data received by the web server when a user starts pushing an RTMP stream to NMS. ```json { id: '4uowyvdy4vpxqcko7ojbphs5qi3qms5e', ip: '[::1]:60116', app: 'live', name: 'stream', query: {}, action: 'postPublish', protocol: 'rtmp', createtime: 1575452695215, endtime: 0, inbytes: 0, outbytes: 0 } ``` -------------------------------- ### Playback Control Source: https://www.nodemedia.cn/document?document=144&project=5 Methods to control the playback of media streams, including starting, stopping, pausing, resuming, and seeking. ```APIDOC ## Playback Control ### `int start(String url)` Start playing the specified media stream/file. #### Parameters - **url** (`String`) - Required - Playback addresses support RTMP, RTSP, HTTP, HTTPS, local files, etc. **Return:** `int` - Startup result (0 for success, non-zero for failure). ### `int stop()` Stop playing. **Return:** `int` - Operation result. ### `int pause(boolean pause)` Pause or resume on-demand video playback. #### Parameters - **pause** (`boolean`) - Required - `true` to pause, `false` to resume. **Return:** `int` - Operation result. ### `int seek(long pts)` Time shift to a specified time point (on-demand only). #### Parameters - **pts** (`long`) - Required - Target time point, in milliseconds. **Return:** `int` - Operation result. ``` -------------------------------- ### Create Electron Project with Vue Source: https://www.nodemedia.cn/document?document=139&project=11 Use the create-electron scaffolding tool to quickly set up a new Electron project with Vue.js. Follow the prompts to configure project name, framework, TypeScript, and other options. ```bash npm create @quick-start/electron ``` ```bash npx > "create-electron" 4. Project name: … electron-app-vue 5. Select a framework: › vue 6. Add TypeScript? … No / Yes 7. Add Electron updater plugin? … No / Yes 8. Enable Electron download mirror proxy? … No / Yes 9. 10. Scaffolding project in /Users/aliang/electron-app-vue... 11. 12. Done. Now run: 13. 14. cd electron-app-vue 15. npm install 16. npm run dev ``` -------------------------------- ### Run NodeMedia Server using Docker (Default Configuration) Source: https://www.nodemedia.cn/document?document=106&project=3 This command deploys NodeMedia Server using Docker with default configurations. It maps standard ports for streaming and management. The container is set to restart automatically. ```bash docker run -d --restart always -p 1935:1935 -p 8000:8000 -p 8443:8443 -p 6935:6935/udp illuspas/nms ``` -------------------------------- ### duration Source: https://www.nodemedia.cn/document?document=146&project=4 Gets the total duration of on-demand video in milliseconds. For live streams, this returns 0. This is a read-only property. ```APIDOC ## duration ### Description Total duration of on-demand video, in milliseconds. Live stream return `0`. This is a read-only property. ### Property - **duration** (NSInteger) - Read-only ``` -------------------------------- ### Configuration Methods Source: https://www.nodemedia.cn/document?document=144&project=5 Methods to configure player settings such as log level, buffer time, and video scaling mode. ```APIDOC ## Configuration Method ### `void setLogLevel(int logLevel)` Set the log output level. #### Parameters - **logLevel** (`int`) - Required - `LOG_LEVEL_ERROR`, `LOG_LEVEL_INFO`, or `LOG_LEVEL_DEBUG`. ### `void setBufferTime(int bufferTime)` Set the cache duration. #### Parameters - **bufferTime** (`int`) - Required - Cache duration, in milliseconds. ### `void setScaleMode(int mode)` Set the video scaling mode. #### Parameters - **mode** (`int`) - Required - Scaling mode (see underlying implementation for specific mode values). ```