expo-mpv 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ {
2
+ "platforms": ["apple"],
3
+ "apple": {
4
+ "modules": ["ExpoMpvModule"]
5
+ }
6
+ }
@@ -0,0 +1,56 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = 'ExpoMpv'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.description = package['description']
10
+ s.license = package['license']
11
+ s.author = package['author']
12
+ s.homepage = package['homepage']
13
+ s.platforms = {
14
+ :ios => '16.0'
15
+ }
16
+ s.swift_version = '5.9'
17
+ s.source = { git: 'https://github.com/lonzzi/expo-mpv' }
18
+ s.static_framework = true
19
+
20
+ s.dependency 'ExpoModulesCore'
21
+
22
+ # Download MPVKit xcframeworks if not present
23
+ s.script_phase = {
24
+ :name => 'Download MPVKit XCFrameworks',
25
+ :script => 'bash "${PODS_TARGET_SRCROOT}/download-mpvkit.sh"',
26
+ :execution_position => :before_compile,
27
+ }
28
+
29
+ # System frameworks required by MPVKit
30
+ s.frameworks = [
31
+ 'Metal',
32
+ 'AVFoundation',
33
+ 'CoreAudio',
34
+ 'AudioToolbox',
35
+ 'CoreVideo',
36
+ 'CoreMedia',
37
+ 'VideoToolbox',
38
+ 'QuartzCore',
39
+ 'CoreFoundation',
40
+ 'IOSurface',
41
+ 'CoreGraphics',
42
+ 'CoreText',
43
+ ]
44
+
45
+ s.libraries = ['bz2', 'iconv', 'expat', 'resolv', 'xml2', 'z', 'c++']
46
+
47
+ # Vendored xcframeworks from download-mpvkit.sh
48
+ s.vendored_frameworks = 'Frameworks/*.xcframework'
49
+
50
+ s.pod_target_xcconfig = {
51
+ 'DEFINES_MODULE' => 'YES',
52
+ 'OTHER_LDFLAGS' => '$(inherited) -ObjC',
53
+ }
54
+
55
+ s.source_files = "*.{h,m,mm,swift,hpp,cpp}"
56
+ end
@@ -0,0 +1,105 @@
1
+ import ExpoModulesCore
2
+
3
+ public class ExpoMpvModule: Module {
4
+ public func definition() -> ModuleDefinition {
5
+ Name("ExpoMpv")
6
+
7
+ // MARK: - View
8
+
9
+ View(ExpoMpvView.self) {
10
+ // Events emitted by the native view
11
+ Events(
12
+ "onPlaybackStateChange",
13
+ "onProgress",
14
+ "onLoad",
15
+ "onError",
16
+ "onEnd",
17
+ "onBuffer",
18
+ "onSeek",
19
+ "onVolumeChange"
20
+ )
21
+
22
+ // MARK: - Props
23
+
24
+ Prop("source") { (view: ExpoMpvView, source: String?) in
25
+ if let source = source {
26
+ view.loadFile(source)
27
+ }
28
+ }
29
+
30
+ Prop("paused") { (view: ExpoMpvView, paused: Bool) in
31
+ if paused {
32
+ view.pause()
33
+ } else {
34
+ view.play()
35
+ }
36
+ }
37
+
38
+ Prop("speed") { (view: ExpoMpvView, speed: Double) in
39
+ view.setSpeed(speed)
40
+ }
41
+
42
+ Prop("volume") { (view: ExpoMpvView, volume: Double) in
43
+ view.setVolume(volume)
44
+ }
45
+
46
+ Prop("muted") { (view: ExpoMpvView, muted: Bool) in
47
+ view.setMuted(muted)
48
+ }
49
+
50
+ Prop("loop") { (view: ExpoMpvView, loop: Bool) in
51
+ view.setLooping(loop)
52
+ }
53
+
54
+ // MARK: - Imperative Functions (called via ref)
55
+
56
+ AsyncFunction("play") { (view: ExpoMpvView) in
57
+ view.play()
58
+ }.runOnQueue(.main)
59
+
60
+ AsyncFunction("pause") { (view: ExpoMpvView) in
61
+ view.pause()
62
+ }.runOnQueue(.main)
63
+
64
+ AsyncFunction("togglePlay") { (view: ExpoMpvView) in
65
+ view.togglePlay()
66
+ }.runOnQueue(.main)
67
+
68
+ AsyncFunction("stop") { (view: ExpoMpvView) in
69
+ view.stop()
70
+ }.runOnQueue(.main)
71
+
72
+ AsyncFunction("seekTo") { (view: ExpoMpvView, position: Double) in
73
+ view.seekTo(position)
74
+ }.runOnQueue(.main)
75
+
76
+ AsyncFunction("seekBy") { (view: ExpoMpvView, offset: Double) in
77
+ view.seekBy(offset)
78
+ }.runOnQueue(.main)
79
+
80
+ AsyncFunction("setSpeed") { (view: ExpoMpvView, speed: Double) in
81
+ view.setSpeed(speed)
82
+ }.runOnQueue(.main)
83
+
84
+ AsyncFunction("setVolume") { (view: ExpoMpvView, volume: Double) in
85
+ view.setVolume(volume)
86
+ }.runOnQueue(.main)
87
+
88
+ AsyncFunction("setMuted") { (view: ExpoMpvView, muted: Bool) in
89
+ view.setMuted(muted)
90
+ }.runOnQueue(.main)
91
+
92
+ AsyncFunction("setSubtitleTrack") { (view: ExpoMpvView, trackId: Int) in
93
+ view.setSubtitleTrack(trackId)
94
+ }.runOnQueue(.main)
95
+
96
+ AsyncFunction("setAudioTrack") { (view: ExpoMpvView, trackId: Int) in
97
+ view.setAudioTrack(trackId)
98
+ }.runOnQueue(.main)
99
+
100
+ AsyncFunction("getPlaybackInfo") { (view: ExpoMpvView) -> [String: Any] in
101
+ return view.getPlaybackInfo()
102
+ }.runOnQueue(.main)
103
+ }
104
+ }
105
+ }