Skip to content

barribarrier/dart_mpv_json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dart MPV JSONIPC

Dart implementation of MPV's IPC interface

Ported from python-mpv-jsonipc

Basic Usage

// Launch MPV and connect to it.
final mpv = await MPV.launch(
  ipcSocket: '/tmp/mpv-socket',
  mpvArgs: {
    'force-window': 'yes',
  },
  logLevel: LogLevel.info,
  logHandler: (level, prefix, text) {
    print('mpv log: $level $prefix $text');
  },
  quitCallback: () {
    print('mpv exited');
  },
);

// or, connect to a running MPV instance connected to /tmp/mpv-socket.
final mpv = await MPV.connect(
  ipcSocket: '/tmp/mpv-socket',
);

// Read and set properties.
print(await mpv.getProperty('volume'));
await mpv.setProperty('volume', 50);

// You can also send commands.
mpv.command('loadfile', ['http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_surround-fix.avi']);

// Bind to a key press event.
mpv.onKey('p', () {
  print('Pressed P');
});

// Bind to an event.
mpv.onEvent('seek', (data) {
  print('Seeked');
});

// Observe property
final unobserveId = await mpv.observeProperty('time-pos', (name, data) {
  print('$name changed to $data');
});

// Unobserve property
await mpv.unobserveProperty(unobserveId);

// Or simply wait for the value to change once.
await mpv.waitForProperty('duration');

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages