mirror of
https://github.com/rive-app/rive-ios.git
synced 2026-01-18 17:11:28 +01:00
add out of band audio support ios - abstracted audio!
Follow up to #7048! I nuked the custom defines and the miniaudio include. I think this fixes the need for miniaudio and the custom defines @mjtalbot! Give it a shot 🔫 Diffs= 89053041a add out of band audio support ios - abstracted audio! (#7079) Co-authored-by: Luigi Rosso <luigi-rosso@users.noreply.github.com> Co-authored-by: Maxwell Talbot <talbot.maxwell@gmail.com>
This commit is contained in:
@@ -1 +1 @@
|
||||
99d28e1ac65672076b08f3a044218ec60268c4ae
|
||||
89053041aea1e6c8559afc4273c4e466e9ff547a
|
||||
|
||||
@@ -1 +1 @@
|
||||
4bdc4c4f5e53d18678bd985df4371b4c3370add3
|
||||
938f5040166c949ae45d991b837b46eab3137ead
|
||||
|
||||
BIN
Example-iOS/Assets/lip-sync_test.riv
Normal file
BIN
Example-iOS/Assets/lip-sync_test.riv
Normal file
Binary file not shown.
BIN
Example-iOS/Assets/ping_pong_audio_demo.riv
Normal file
BIN
Example-iOS/Assets/ping_pong_audio_demo.riv
Normal file
Binary file not shown.
BIN
Example-iOS/Assets/racket1-59343.wav
Normal file
BIN
Example-iOS/Assets/racket1-59343.wav
Normal file
Binary file not shown.
BIN
Example-iOS/Assets/racket2-59344.wav
Normal file
BIN
Example-iOS/Assets/racket2-59344.wav
Normal file
Binary file not shown.
BIN
Example-iOS/Assets/table-59328.wav
Normal file
BIN
Example-iOS/Assets/table-59328.wav
Normal file
Binary file not shown.
@@ -194,6 +194,20 @@
|
||||
046AFA712673AF04004ED497 /* blendmodes.riv in Resources */ = {isa = PBXBuildFile; fileRef = 046AFA6E2673AF04004ED497 /* blendmodes.riv */; };
|
||||
046AFA732673B00B004ED497 /* BlendModes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 046AFA722673B00B004ED497 /* BlendModes.swift */; };
|
||||
0480028B2729AA4400F7132B /* clean_icon_set.riv in Resources */ = {isa = PBXBuildFile; fileRef = 048002882729AA4400F7132B /* clean_icon_set.riv */; };
|
||||
0490914C2BC8326E00F2C12B /* SwiftAudioAssets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0490914B2BC8326E00F2C12B /* SwiftAudioAssets.swift */; };
|
||||
0490914D2BC8326E00F2C12B /* SwiftAudioAssets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0490914B2BC8326E00F2C12B /* SwiftAudioAssets.swift */; };
|
||||
049091542BC832B000F2C12B /* racket1-59343.wav in Resources */ = {isa = PBXBuildFile; fileRef = 049091502BC832AE00F2C12B /* racket1-59343.wav */; };
|
||||
049091552BC832B000F2C12B /* racket1-59343.wav in Resources */ = {isa = PBXBuildFile; fileRef = 049091502BC832AE00F2C12B /* racket1-59343.wav */; };
|
||||
049091562BC832B000F2C12B /* racket2-59344.wav in Resources */ = {isa = PBXBuildFile; fileRef = 049091512BC832AF00F2C12B /* racket2-59344.wav */; };
|
||||
049091572BC832B000F2C12B /* racket2-59344.wav in Resources */ = {isa = PBXBuildFile; fileRef = 049091512BC832AF00F2C12B /* racket2-59344.wav */; };
|
||||
049091582BC832B000F2C12B /* ping_pong_audio_demo.riv in Resources */ = {isa = PBXBuildFile; fileRef = 049091522BC832AF00F2C12B /* ping_pong_audio_demo.riv */; };
|
||||
049091592BC832B000F2C12B /* ping_pong_audio_demo.riv in Resources */ = {isa = PBXBuildFile; fileRef = 049091522BC832AF00F2C12B /* ping_pong_audio_demo.riv */; };
|
||||
0490915A2BC832B000F2C12B /* table-59328.wav in Resources */ = {isa = PBXBuildFile; fileRef = 049091532BC832B000F2C12B /* table-59328.wav */; };
|
||||
0490915B2BC832B000F2C12B /* table-59328.wav in Resources */ = {isa = PBXBuildFile; fileRef = 049091532BC832B000F2C12B /* table-59328.wav */; };
|
||||
0490915D2BC832D100F2C12B /* lip-sync_test.riv in Resources */ = {isa = PBXBuildFile; fileRef = 0490915C2BC832D100F2C12B /* lip-sync_test.riv */; };
|
||||
0490915E2BC832D100F2C12B /* lip-sync_test.riv in Resources */ = {isa = PBXBuildFile; fileRef = 0490915C2BC832D100F2C12B /* lip-sync_test.riv */; };
|
||||
049091632BC948AA00F2C12B /* SwiftOutOfBandAudioAssets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049091622BC948AA00F2C12B /* SwiftOutOfBandAudioAssets.swift */; };
|
||||
049091642BC948AA00F2C12B /* SwiftOutOfBandAudioAssets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049091622BC948AA00F2C12B /* SwiftOutOfBandAudioAssets.swift */; };
|
||||
04C4C83E2646FE410047E614 /* StateMachine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04C4C83D2646FE410047E614 /* StateMachine.swift */; };
|
||||
04D5B06C266A460C004ACA5B /* nothing.riv in Resources */ = {isa = PBXBuildFile; fileRef = 04D5B069266A460C004ACA5B /* nothing.riv */; };
|
||||
04DB5937266A348C0020A7E8 /* RiveRuntime.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 04A8F6BD26452E10002C909A /* RiveRuntime.framework */; };
|
||||
@@ -388,6 +402,13 @@
|
||||
046AFA6E2673AF04004ED497 /* blendmodes.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = blendmodes.riv; sourceTree = "<group>"; };
|
||||
046AFA722673B00B004ED497 /* BlendModes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlendModes.swift; sourceTree = "<group>"; };
|
||||
048002882729AA4400F7132B /* clean_icon_set.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = clean_icon_set.riv; sourceTree = "<group>"; };
|
||||
0490914B2BC8326E00F2C12B /* SwiftAudioAssets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftAudioAssets.swift; sourceTree = "<group>"; };
|
||||
049091502BC832AE00F2C12B /* racket1-59343.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = "racket1-59343.wav"; sourceTree = "<group>"; };
|
||||
049091512BC832AF00F2C12B /* racket2-59344.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = "racket2-59344.wav"; sourceTree = "<group>"; };
|
||||
049091522BC832AF00F2C12B /* ping_pong_audio_demo.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = ping_pong_audio_demo.riv; sourceTree = "<group>"; };
|
||||
049091532BC832B000F2C12B /* table-59328.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = "table-59328.wav"; sourceTree = "<group>"; };
|
||||
0490915C2BC832D100F2C12B /* lip-sync_test.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = "lip-sync_test.riv"; sourceTree = "<group>"; };
|
||||
049091622BC948AA00F2C12B /* SwiftOutOfBandAudioAssets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftOutOfBandAudioAssets.swift; sourceTree = "<group>"; };
|
||||
04A8F6AB26452A91002C909A /* RiveRuntime.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RiveRuntime.xcodeproj; path = ../RiveRuntime.xcodeproj; sourceTree = "<group>"; };
|
||||
04C4C83D2646FE410047E614 /* StateMachine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StateMachine.swift; sourceTree = "<group>"; };
|
||||
04D5B069266A460C004ACA5B /* nothing.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = nothing.riv; sourceTree = "<group>"; };
|
||||
@@ -562,6 +583,11 @@
|
||||
C9696B0E24FC6FD10041502A /* Assets */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0490915C2BC832D100F2C12B /* lip-sync_test.riv */,
|
||||
049091522BC832AF00F2C12B /* ping_pong_audio_demo.riv */,
|
||||
049091502BC832AE00F2C12B /* racket1-59343.wav */,
|
||||
049091512BC832AF00F2C12B /* racket2-59344.wav */,
|
||||
049091532BC832B000F2C12B /* table-59328.wav */,
|
||||
E5B5C2172B238829006E57C8 /* asset_load_check.riv */,
|
||||
043026052B012C5000320F2E /* simple_assets.riv */,
|
||||
0453FCB02B012D17001185C8 /* picture-47982.jpeg */,
|
||||
@@ -634,6 +660,8 @@
|
||||
E57798A82A730A9B00FF25C3 /* SwiftTestText.swift */,
|
||||
E5964AAA2A9CD49200140479 /* SwiftEvents.swift */,
|
||||
041265212B0BC5A5009400EC /* SwiftSimpleAssets.swift */,
|
||||
0490914B2BC8326E00F2C12B /* SwiftAudioAssets.swift */,
|
||||
049091622BC948AA00F2C12B /* SwiftOutOfBandAudioAssets.swift */,
|
||||
);
|
||||
path = SwiftUI;
|
||||
sourceTree = "<group>";
|
||||
@@ -910,7 +938,9 @@
|
||||
040553F72B7A2858008F076A /* truck_v7.riv in Resources */,
|
||||
040553F82B7A2858008F076A /* pull.riv in Resources */,
|
||||
040553F92B7A2858008F076A /* flux_capacitor.riv in Resources */,
|
||||
049091542BC832B000F2C12B /* racket1-59343.wav in Resources */,
|
||||
040553FA2B7A2858008F076A /* testtext.riv in Resources */,
|
||||
0490915D2BC832D100F2C12B /* lip-sync_test.riv in Resources */,
|
||||
040553FB2B7A2858008F076A /* juice_v7.riv in Resources */,
|
||||
040553FC2B7A2858008F076A /* play_button_event_example.riv in Resources */,
|
||||
040553FD2B7A2858008F076A /* neostream.riv in Resources */,
|
||||
@@ -924,6 +954,7 @@
|
||||
040554052B7A2858008F076A /* skills.riv in Resources */,
|
||||
040554062B7A2858008F076A /* artboard_animations.riv in Resources */,
|
||||
040554072B7A2858008F076A /* trailblaze.riv in Resources */,
|
||||
049091582BC832B000F2C12B /* ping_pong_audio_demo.riv in Resources */,
|
||||
040554082B7A2858008F076A /* riveslider.riv in Resources */,
|
||||
040554092B7A2858008F076A /* marty.riv in Resources */,
|
||||
0405540A2B7A2858008F076A /* leg_day_events_example.riv in Resources */,
|
||||
@@ -931,6 +962,7 @@
|
||||
0405540C2B7A2858008F076A /* rope.riv in Resources */,
|
||||
0405540D2B7A2858008F076A /* teststatemachine.riv in Resources */,
|
||||
0405540E2B7A2858008F076A /* switch_event_example.riv in Resources */,
|
||||
049091562BC832B000F2C12B /* racket2-59344.wav in Resources */,
|
||||
0405540F2B7A2858008F076A /* clean_icon_set.riv in Resources */,
|
||||
040554102B7A2858008F076A /* text_test_2.riv in Resources */,
|
||||
040554112B7A2858008F076A /* two_bone_ik.riv in Resources */,
|
||||
@@ -955,6 +987,7 @@
|
||||
040554242B7A2858008F076A /* life_bar.riv in Resources */,
|
||||
040554252B7A2858008F076A /* wacky.riv in Resources */,
|
||||
040554262B7A2858008F076A /* asset_load_check.riv in Resources */,
|
||||
0490915A2BC832B000F2C12B /* table-59328.wav in Resources */,
|
||||
040554272B7A2858008F076A /* energy_bar_example.riv in Resources */,
|
||||
040554282B7A2858008F076A /* clipping.riv in Resources */,
|
||||
040554292B7A2858008F076A /* watch_v1.riv in Resources */,
|
||||
@@ -1034,7 +1067,9 @@
|
||||
C9BD3926263B5FC700696C37 /* truck_v7.riv in Resources */,
|
||||
042C88DC2644447500E7DBB2 /* pull.riv in Resources */,
|
||||
042C88E32644447500E7DBB2 /* flux_capacitor.riv in Resources */,
|
||||
049091552BC832B000F2C12B /* racket1-59343.wav in Resources */,
|
||||
E57798A02A72C77900FF25C3 /* testtext.riv in Resources */,
|
||||
0490915E2BC832D100F2C12B /* lip-sync_test.riv in Resources */,
|
||||
C9CE8266263B90E000F98DDB /* juice_v7.riv in Resources */,
|
||||
C3ECAC2B281837B300A81123 /* play_button_event_example.riv in Resources */,
|
||||
042C88E42644447500E7DBB2 /* neostream.riv in Resources */,
|
||||
@@ -1048,6 +1083,7 @@
|
||||
042C88EA2644447500E7DBB2 /* skills.riv in Resources */,
|
||||
042C88E62644447500E7DBB2 /* artboard_animations.riv in Resources */,
|
||||
042C88E72644447500E7DBB2 /* trailblaze.riv in Resources */,
|
||||
049091592BC832B000F2C12B /* ping_pong_audio_demo.riv in Resources */,
|
||||
C3D187F728075B6C008B739A /* riveslider.riv in Resources */,
|
||||
83C89ACF2988709400044C17 /* marty.riv in Resources */,
|
||||
C3ECAC2C281837B300A81123 /* leg_day_events_example.riv in Resources */,
|
||||
@@ -1055,6 +1091,7 @@
|
||||
042C88DE2644447500E7DBB2 /* rope.riv in Resources */,
|
||||
C3C074AC283FC75900E8EB33 /* teststatemachine.riv in Resources */,
|
||||
C3ECAC2D281837B300A81123 /* switch_event_example.riv in Resources */,
|
||||
049091572BC832B000F2C12B /* racket2-59344.wav in Resources */,
|
||||
0480028B2729AA4400F7132B /* clean_icon_set.riv in Resources */,
|
||||
E57798AE2A73264100FF25C3 /* text_test_2.riv in Resources */,
|
||||
04F1C80B26A8442300CEE6BE /* two_bone_ik.riv in Resources */,
|
||||
@@ -1079,6 +1116,7 @@
|
||||
C9D3DE68264F49F4001BA265 /* life_bar.riv in Resources */,
|
||||
042C88DB2644447500E7DBB2 /* wacky.riv in Resources */,
|
||||
E5B5C2182B238829006E57C8 /* asset_load_check.riv in Resources */,
|
||||
0490915B2BC832B000F2C12B /* table-59328.wav in Resources */,
|
||||
E5A7874A27E115170056F24B /* energy_bar_example.riv in Resources */,
|
||||
042C88EB2644447500E7DBB2 /* clipping.riv in Resources */,
|
||||
C3E383482837E6B00029D65E /* watch_v1.riv in Resources */,
|
||||
@@ -1107,6 +1145,7 @@
|
||||
040553D32B7A2858008F076A /* SimpleHttpAnimation.swift in Sources */,
|
||||
040553D42B7A2858008F076A /* RiveButton.swift in Sources */,
|
||||
040553D52B7A2858008F076A /* AppDelegate.swift in Sources */,
|
||||
0490914C2BC8326E00F2C12B /* SwiftAudioAssets.swift in Sources */,
|
||||
040553D62B7A2858008F076A /* SwiftCannonGame.swift in Sources */,
|
||||
040553D72B7A2858008F076A /* SwiftWidgets.swift in Sources */,
|
||||
040553D82B7A2858008F076A /* utility.swift in Sources */,
|
||||
@@ -1128,6 +1167,7 @@
|
||||
040553E82B7A2858008F076A /* RiveSlider.swift in Sources */,
|
||||
040553E92B7A2858008F076A /* Layout.swift in Sources */,
|
||||
040553EA2B7A2858008F076A /* BlendModes.swift in Sources */,
|
||||
049091632BC948AA00F2C12B /* SwiftOutOfBandAudioAssets.swift in Sources */,
|
||||
040553EB2B7A2858008F076A /* SwiftMultipleAnimations.swift in Sources */,
|
||||
040553EC2B7A2858008F076A /* SimpleAnimation.swift in Sources */,
|
||||
040553ED2B7A2858008F076A /* SwiftSimpleAnimation.swift in Sources */,
|
||||
@@ -1156,6 +1196,7 @@
|
||||
0448838F29F82DD000D7523E /* SimpleHttpAnimation.swift in Sources */,
|
||||
C324DB5D280728690060589F /* RiveButton.swift in Sources */,
|
||||
C9C73E9824FC471E00EF9516 /* AppDelegate.swift in Sources */,
|
||||
0490914D2BC8326E00F2C12B /* SwiftAudioAssets.swift in Sources */,
|
||||
C3E2B58C2833ECFE00A8651B /* SwiftCannonGame.swift in Sources */,
|
||||
C9CB2F13264C92D200E7FF0D /* SwiftWidgets.swift in Sources */,
|
||||
042C888E2644230700E7DBB2 /* utility.swift in Sources */,
|
||||
@@ -1177,6 +1218,7 @@
|
||||
C324DB5B2807216B0060589F /* RiveSlider.swift in Sources */,
|
||||
042C888C2643EEE300E7DBB2 /* Layout.swift in Sources */,
|
||||
046AFA732673B00B004ED497 /* BlendModes.swift in Sources */,
|
||||
049091642BC948AA00F2C12B /* SwiftOutOfBandAudioAssets.swift in Sources */,
|
||||
04026DCA27CE3EF6002B3DBF /* SwiftMultipleAnimations.swift in Sources */,
|
||||
042C88882643DB7100E7DBB2 /* SimpleAnimation.swift in Sources */,
|
||||
04026DC427CE3ED6002B3DBF /* SwiftSimpleAnimation.swift in Sources */,
|
||||
|
||||
25
Example-iOS/Source/Examples/SwiftUI/SwiftAudioAssets.swift
Normal file
25
Example-iOS/Source/Examples/SwiftUI/SwiftAudioAssets.swift
Normal file
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// SwiftAudioAssets.swift
|
||||
// RiveExample
|
||||
//
|
||||
// Created by Maxwell Talbot on 11/04/2024.
|
||||
// Copyright © 2024 Rive. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
import SwiftUI
|
||||
import RiveRuntime
|
||||
|
||||
struct SwiftAudioAssets: DismissableView {
|
||||
var dismiss: () -> Void = {}
|
||||
@StateObject private var riveViewModel = RiveViewModel(
|
||||
fileName: "lip-sync_test",
|
||||
stateMachineName: "State Machine 1",
|
||||
artboardName: "Lip_sync_2"
|
||||
);
|
||||
|
||||
var body: some View {
|
||||
riveViewModel.view()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
//
|
||||
// SwiftAudioAssets.swift
|
||||
// RiveExample
|
||||
//
|
||||
// Created by Maxwell Talbot on 11/04/2024.
|
||||
// Copyright © 2024 Rive. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
import SwiftUI
|
||||
import RiveRuntime
|
||||
|
||||
struct SwiftOutOfBandAudioAssets: DismissableView {
|
||||
var dismiss: () -> Void = {}
|
||||
@StateObject private var riveViewModel = RiveViewModel(
|
||||
fileName: "ping_pong_audio_demo",
|
||||
stateMachineName: "State Machine 1",
|
||||
autoPlay: true,
|
||||
loadCdn: false,
|
||||
customLoader: { (asset: RiveFileAsset, data: Data, factory: RiveFactory) -> Bool in
|
||||
|
||||
if (asset is RiveAudioAsset){
|
||||
guard let url = (.main as Bundle).url(forResource: asset.uniqueName(), withExtension: asset.fileExtension()) else {
|
||||
fatalError("Failed to load asset \(asset.uniqueFilename()) from bundle.")
|
||||
}
|
||||
guard let data = try? Data(contentsOf: url) else {
|
||||
fatalError("Failed to load \(url) from bundle.")
|
||||
}
|
||||
|
||||
(asset as! RiveAudioAsset).audio(
|
||||
factory.decodeAudio(data)
|
||||
)
|
||||
return true;
|
||||
|
||||
}
|
||||
//
|
||||
return true;
|
||||
}
|
||||
);
|
||||
|
||||
var body: some View {
|
||||
|
||||
riveViewModel.view()
|
||||
}
|
||||
}
|
||||
@@ -15,8 +15,8 @@ struct SwiftSimpleAssets: DismissableView {
|
||||
|
||||
if (asset is RiveImageAsset){
|
||||
|
||||
guard let url = (.main as Bundle).url(forResource: "picture-47982", withExtension: "jpeg") else {
|
||||
fatalError("Failed to locate 'picture-47982' in bundle.")
|
||||
guard let url = (.main as Bundle).url(forResource: asset.uniqueName(), withExtension: "jpeg") else {
|
||||
fatalError("Failed to locate '\(asset.uniqueName())' in bundle.")
|
||||
}
|
||||
guard let data = try? Data(contentsOf: url) else {
|
||||
fatalError("Failed to load \(url) from bundle.")
|
||||
@@ -26,8 +26,8 @@ struct SwiftSimpleAssets: DismissableView {
|
||||
)
|
||||
return true;
|
||||
}else if (asset is RiveFontAsset) {
|
||||
guard let url = (.main as Bundle).url(forResource: "Inter-45562", withExtension: "ttf") else {
|
||||
fatalError("Failed to locate 'Inter-45562' in bundle.")
|
||||
guard let url = (.main as Bundle).url(forResource: asset.uniqueName(), withExtension: asset.fileExtension()) else {
|
||||
fatalError("Failed to locate '\(asset.uniqueName())' in bundle.")
|
||||
}
|
||||
guard let data = try? Data(contentsOf: url) else {
|
||||
fatalError("Failed to load \(url) from bundle.")
|
||||
|
||||
@@ -24,6 +24,7 @@ class ExamplesMasterTableViewController: UITableViewController {
|
||||
"Stress Test",
|
||||
"Simple assets",
|
||||
"Cached assets",
|
||||
|
||||
]
|
||||
|
||||
|
||||
@@ -41,7 +42,9 @@ class ExamplesMasterTableViewController: UITableViewController {
|
||||
("Playing with Text", typeErased(dismissableView: TextInputView())),
|
||||
("Rive Events", typeErased(dismissableView: SwiftEvents())),
|
||||
("Variable FPS", typeErased(dismissableView: SwiftVariableFPS())),
|
||||
("Simple Assets", typeErased(dismissableView: SwiftSimpleAssets()))
|
||||
("Simple Assets", typeErased(dismissableView: SwiftSimpleAssets())),
|
||||
("Audio Assets", typeErased(dismissableView: SwiftAudioAssets())),
|
||||
("External Audio Assets", typeErased(dismissableView: SwiftOutOfBandAudioAssets()))
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
041265262B0CB41E009400EC /* OutOfBandAssetTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 041265252B0CB41E009400EC /* OutOfBandAssetTest.mm */; };
|
||||
041265282B0CC387009400EC /* hosted_assets.riv in Resources */ = {isa = PBXBuildFile; fileRef = 041265272B0CC387009400EC /* hosted_assets.riv */; };
|
||||
0412652A2B0CCB8E009400EC /* embedded_assets.riv in Resources */ = {isa = PBXBuildFile; fileRef = 041265292B0CCB8E009400EC /* embedded_assets.riv */; };
|
||||
0424A8742BD592F2000A9A1C /* audio_test.riv in Resources */ = {isa = PBXBuildFile; fileRef = 0424A8732BD592F2000A9A1C /* audio_test.riv */; };
|
||||
0424A8762BD59435000A9A1C /* img_test.riv in Resources */ = {isa = PBXBuildFile; fileRef = 0424A8752BD59435000A9A1C /* img_test.riv */; };
|
||||
043025F22AF90D4800320F2E /* RiveFileAssetLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 043025F12AF90D4800320F2E /* RiveFileAssetLoader.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
043025F42AF90EAC00320F2E /* RiveFileAssetLoader.mm in Sources */ = {isa = PBXBuildFile; fileRef = 043025F32AF90EAC00320F2E /* RiveFileAssetLoader.mm */; };
|
||||
043025F62AF9355B00320F2E /* CDNFileAssetLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 043025F52AF9355B00320F2E /* CDNFileAssetLoader.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
@@ -107,6 +109,8 @@
|
||||
041265252B0CB41E009400EC /* OutOfBandAssetTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = OutOfBandAssetTest.mm; sourceTree = "<group>"; };
|
||||
041265272B0CC387009400EC /* hosted_assets.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = hosted_assets.riv; sourceTree = "<group>"; };
|
||||
041265292B0CCB8E009400EC /* embedded_assets.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = embedded_assets.riv; sourceTree = "<group>"; };
|
||||
0424A8732BD592F2000A9A1C /* audio_test.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = audio_test.riv; sourceTree = "<group>"; };
|
||||
0424A8752BD59435000A9A1C /* img_test.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = img_test.riv; sourceTree = "<group>"; };
|
||||
043025F12AF90D4800320F2E /* RiveFileAssetLoader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RiveFileAssetLoader.h; sourceTree = "<group>"; };
|
||||
043025F32AF90EAC00320F2E /* RiveFileAssetLoader.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = RiveFileAssetLoader.mm; sourceTree = "<group>"; };
|
||||
043025F52AF9355B00320F2E /* CDNFileAssetLoader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CDNFileAssetLoader.h; sourceTree = "<group>"; };
|
||||
@@ -247,6 +251,8 @@
|
||||
04BE53F726493FE600427B39 /* Assets */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0424A8752BD59435000A9A1C /* img_test.riv */,
|
||||
0424A8732BD592F2000A9A1C /* audio_test.riv */,
|
||||
041265272B0CC387009400EC /* hosted_assets.riv */,
|
||||
041265292B0CCB8E009400EC /* embedded_assets.riv */,
|
||||
C38BB5F3287629C20039E385 /* defaultstatemachine.riv */,
|
||||
@@ -507,6 +513,7 @@
|
||||
C38BB5F4287629C20039E385 /* defaultstatemachine.riv in Resources */,
|
||||
04BE54082649403600427B39 /* flux_capacitor.riv in Resources */,
|
||||
04BE54052649403600427B39 /* noartboard.riv in Resources */,
|
||||
0424A8742BD592F2000A9A1C /* audio_test.riv in Resources */,
|
||||
0412652A2B0CCB8E009400EC /* embedded_assets.riv in Resources */,
|
||||
04BE540B2649403600427B39 /* multiple_animations.riv in Resources */,
|
||||
041265282B0CC387009400EC /* hosted_assets.riv in Resources */,
|
||||
@@ -518,6 +525,7 @@
|
||||
04BE540D2649403600427B39 /* junk.riv in Resources */,
|
||||
04BE54092649403600427B39 /* state_machine_configurations.riv in Resources */,
|
||||
04BE54072649403600427B39 /* what_a_state.riv in Resources */,
|
||||
0424A8762BD59435000A9A1C /* img_test.riv in Resources */,
|
||||
04BE541A264A823000427B39 /* animationconfigurations.riv in Resources */,
|
||||
04BE540E2649403600427B39 /* multiple_state_machines.riv in Resources */,
|
||||
);
|
||||
|
||||
@@ -36,6 +36,12 @@ bool rive::FileAssetLoaderAdapter::loadContents(rive::FileAsset& asset,
|
||||
[[RiveImageAsset alloc] initWithFileAsset:asset.as<rive::ImageAsset>()];
|
||||
return [loader loadContentsWithAsset:imageAsset andData:data andFactory:myFactory];
|
||||
}
|
||||
else if (asset.is<rive::AudioAsset>())
|
||||
{
|
||||
RiveAudioAsset* audioAsset =
|
||||
[[RiveAudioAsset alloc] initWithFileAsset:asset.as<rive::AudioAsset>()];
|
||||
return [loader loadContentsWithAsset:audioAsset andData:data andFactory:myFactory];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,29 @@
|
||||
|
||||
@end
|
||||
|
||||
@implementation RiveAudio
|
||||
{
|
||||
rive::rcp<rive::AudioSource> instance; // note: we do NOT own this, so don't delete it
|
||||
}
|
||||
- (instancetype)initWithAudio:(rive::rcp<rive::AudioSource>)audio
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
instance = audio;
|
||||
return self;
|
||||
}
|
||||
else
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
- (rive::rcp<rive::AudioSource>)instance
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/*
|
||||
* RiveFactory
|
||||
*/
|
||||
@@ -92,4 +115,11 @@
|
||||
initWithFont:instance->decodeFont(rive::Span<const uint8_t>(bytes, [data length]))];
|
||||
}
|
||||
|
||||
- (RiveAudio*)decodeAudio:(nonnull NSData*)data
|
||||
{
|
||||
UInt8* bytes = (UInt8*)[data bytes];
|
||||
return [[RiveAudio alloc]
|
||||
initWithAudio:instance->decodeAudio(rive::Span<const uint8_t>(bytes, [data length]))];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -62,6 +62,12 @@
|
||||
return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]];
|
||||
}
|
||||
|
||||
- (nonnull NSString*)uniqueName
|
||||
{
|
||||
std::string str = instance->uniqueName();
|
||||
return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation RiveImageAsset
|
||||
@@ -89,3 +95,15 @@
|
||||
((rive::FontAsset*)[self getInstance])->font([font instance]);
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation RiveAudioAsset
|
||||
- (instancetype)initWithFileAsset:(const rive::AudioAsset*)fileAsset
|
||||
{
|
||||
return [super initWithFileAsset:fileAsset];
|
||||
}
|
||||
|
||||
- (void)audio:(RiveAudio*)audio
|
||||
{
|
||||
((rive::AudioAsset*)[self getInstance])->audioSource([audio instance]);
|
||||
}
|
||||
@end
|
||||
|
||||
@@ -19,12 +19,16 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@interface RiveRenderImage : NSObject
|
||||
@end
|
||||
|
||||
@interface RiveAudio : NSObject
|
||||
@end
|
||||
|
||||
/*
|
||||
* RiveFactory
|
||||
*/
|
||||
@interface RiveFactory : NSObject
|
||||
- (RiveFont*)decodeFont:(NSData*)data;
|
||||
- (RiveRenderImage*)decodeImage:(NSData*)data;
|
||||
- (RiveAudio*)decodeAudio:(NSData*)data;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
@class RiveRenderImage;
|
||||
@class RiveFont;
|
||||
@class RiveAudio;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@@ -22,6 +23,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@interface RiveFileAsset : NSObject
|
||||
// TODO: add an asset type?
|
||||
- (NSString*)name;
|
||||
- (NSString*)uniqueName;
|
||||
- (NSString*)uniqueFilename;
|
||||
- (NSString*)fileExtension;
|
||||
- (NSString*)cdnBaseUrl;
|
||||
@@ -36,12 +38,19 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@end
|
||||
|
||||
/*
|
||||
* SMIBool
|
||||
* RiveFontAsset
|
||||
*/
|
||||
@interface RiveFontAsset : RiveFileAsset
|
||||
- (void)font:(RiveFont*)font;
|
||||
@end
|
||||
|
||||
/*
|
||||
* RiveAudioAsset
|
||||
*/
|
||||
@interface RiveAudioAsset : RiveFileAsset
|
||||
- (void)audio:(RiveAudio*)audio;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
#endif /* RiveFileAsset_h */
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#import "rive/event.hpp"
|
||||
#import "rive/assets/image_asset.hpp"
|
||||
#import "rive/assets/font_asset.hpp"
|
||||
#import "rive/assets/audio_asset.hpp"
|
||||
#import "rive/assets/file_asset.hpp"
|
||||
#import "rive/file_asset_loader.hpp"
|
||||
|
||||
@@ -130,12 +131,19 @@
|
||||
@end
|
||||
|
||||
/*
|
||||
* SMIBool
|
||||
* RiveFontAsset
|
||||
*/
|
||||
@interface RiveFontAsset ()
|
||||
- (instancetype)initWithFileAsset:(const rive::FontAsset*)fileAsset;
|
||||
@end
|
||||
|
||||
/*
|
||||
* RiveAudioAsset
|
||||
*/
|
||||
@interface RiveAudioAsset ()
|
||||
- (instancetype)initWithFileAsset:(const rive::AudioAsset*)fileAsset;
|
||||
@end
|
||||
|
||||
/*
|
||||
* RiveFileAsset
|
||||
*/
|
||||
@@ -152,3 +160,8 @@
|
||||
- (instancetype)initWithImage:(rive::rcp<rive::RenderImage>)image;
|
||||
- (rive::rcp<rive::RenderImage>)instance;
|
||||
@end
|
||||
|
||||
@interface RiveAudio ()
|
||||
- (instancetype)initWithAudio:(rive::rcp<rive::AudioSource>)audio;
|
||||
- (rive::rcp<rive::AudioSource>)instance;
|
||||
@end
|
||||
|
||||
BIN
Tests/Assets/audio_test.riv
Normal file
BIN
Tests/Assets/audio_test.riv
Normal file
Binary file not shown.
BIN
Tests/Assets/img_test.riv
Normal file
BIN
Tests/Assets/img_test.riv
Normal file
Binary file not shown.
@@ -49,6 +49,7 @@
|
||||
XCTAssertNotNil(image);
|
||||
XCTAssertEqual(imageData.length, 0);
|
||||
XCTAssertEqualObjects([image name], @"image.png");
|
||||
XCTAssertEqualObjects([image uniqueName], @"image-49934");
|
||||
XCTAssertEqualObjects([image uniqueFilename], @"image-49934.png");
|
||||
XCTAssertEqualObjects([image fileExtension], @"png");
|
||||
XCTAssertEqualObjects([image cdnBaseUrl], @"https://public.uat.rive.app/cdn/uuid");
|
||||
@@ -57,12 +58,111 @@
|
||||
XCTAssertNotNil(font);
|
||||
XCTAssertEqual(fontData.length, 0);
|
||||
XCTAssertEqualObjects([font name], @"Inter");
|
||||
XCTAssertEqualObjects([font uniqueName], @"Inter-45562");
|
||||
XCTAssertEqualObjects([font uniqueFilename], @"Inter-45562.ttf");
|
||||
XCTAssertEqualObjects([font fileExtension], @"ttf");
|
||||
XCTAssertEqualObjects([font cdnBaseUrl], @"https://public.uat.rive.app/cdn/uuid");
|
||||
XCTAssertEqualObjects([font cdnUuid], @"60ad5ede-993c-4e03-9a80-e56888b2cff3");
|
||||
}
|
||||
|
||||
- (void)testAudioAssetCallbacks
|
||||
{
|
||||
NSError* error = nil;
|
||||
NSData* data = [Util loadTestData:@"audio_test"];
|
||||
__block RiveAudioAsset* hosted;
|
||||
__block RiveAudioAsset* embedded;
|
||||
|
||||
__block NSData* hostedData;
|
||||
__block NSData* embeddedData;
|
||||
|
||||
RiveFile* file = [[RiveFile alloc]
|
||||
initWithData:data
|
||||
loadCdn:false
|
||||
customAssetLoader:^bool(RiveFileAsset* asset, NSData* data, RiveFactory* factory) {
|
||||
if ([asset isKindOfClass:[RiveAudioAsset class]])
|
||||
{
|
||||
if (data.length > 0)
|
||||
{
|
||||
embedded = (RiveAudioAsset*)asset;
|
||||
embeddedData = data;
|
||||
}
|
||||
else
|
||||
{
|
||||
hosted = (RiveAudioAsset*)asset;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
error:&error];
|
||||
|
||||
XCTAssertNotNil(file);
|
||||
XCTAssertNil(error);
|
||||
|
||||
XCTAssertNotNil(hosted);
|
||||
XCTAssertEqual(hostedData.length, 0);
|
||||
XCTAssertEqualObjects([hosted name], @"hosted");
|
||||
XCTAssertEqualObjects([hosted uniqueName], @"hosted-55368");
|
||||
XCTAssertEqualObjects([hosted uniqueFilename], @"hosted-55368.wav");
|
||||
XCTAssertEqualObjects([hosted fileExtension], @"wav");
|
||||
XCTAssertEqualObjects([hosted cdnBaseUrl], @"https://public.uat.rive.app/cdn/uuid");
|
||||
XCTAssertEqualObjects([hosted cdnUuid], @"79b65f1e-94ea-4191-b5ad-b3d5495b6343");
|
||||
|
||||
XCTAssertNotNil(embedded);
|
||||
XCTAssertEqual(embeddedData.length, 26095);
|
||||
XCTAssertEqualObjects([embedded name], @"embedded");
|
||||
// TODO: fix asset export issue and re-export test file
|
||||
XCTAssertEqualObjects([embedded uniqueName], @"embedded-0");
|
||||
XCTAssertEqualObjects([embedded uniqueFilename], @"embedded-0.wav");
|
||||
XCTAssertEqualObjects([embedded fileExtension], @"wav");
|
||||
XCTAssertEqualObjects([embedded cdnBaseUrl], @"https://public.rive.app/cdn/uuid");
|
||||
XCTAssertEqualObjects([embedded cdnUuid], @"");
|
||||
}
|
||||
|
||||
- (void)testImageTypesCallbacks
|
||||
{
|
||||
XCTSkip("File extensions are not returning correct values at this point.");
|
||||
NSError* error = nil;
|
||||
NSData* data = [Util loadTestData:@"img_test"];
|
||||
__block RiveImageAsset* png;
|
||||
__block RiveImageAsset* webp;
|
||||
__block RiveImageAsset* jpeg;
|
||||
|
||||
RiveFile* file = [[RiveFile alloc]
|
||||
initWithData:data
|
||||
loadCdn:false
|
||||
customAssetLoader:^bool(RiveFileAsset* asset, NSData* data, RiveFactory* factory) {
|
||||
if ([asset isKindOfClass:[RiveImageAsset class]])
|
||||
{
|
||||
|
||||
if ([asset.fileExtension isEqual:@"png"])
|
||||
{
|
||||
png = (RiveImageAsset*)asset;
|
||||
}
|
||||
else if ([asset.fileExtension isEqual:@"webp"])
|
||||
{
|
||||
webp = (RiveImageAsset*)asset;
|
||||
}
|
||||
else if ([asset.fileExtension isEqual:@"jpeg"])
|
||||
{
|
||||
jpeg = (RiveImageAsset*)asset;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
error:&error];
|
||||
|
||||
XCTAssertNotNil(file);
|
||||
XCTAssertNil(error);
|
||||
|
||||
XCTAssertNotNil(webp);
|
||||
XCTAssertEqualObjects([webp fileExtension], @"webp");
|
||||
XCTAssertNotNil(png);
|
||||
XCTAssertEqualObjects([png fileExtension], @"png");
|
||||
XCTAssertNotNil(jpeg);
|
||||
XCTAssertEqualObjects([jpeg fileExtension], @"jpeg");
|
||||
XCTAssertEqualObjects([jpeg uniqueFilename], @"hosted-55368.wav");
|
||||
}
|
||||
|
||||
- (void)testEmbeddedAssetsProvideData
|
||||
{
|
||||
NSError* error = nil;
|
||||
|
||||
@@ -61,7 +61,7 @@ build_runtime() {
|
||||
|
||||
# Build rive_pls_renderer.
|
||||
pushd $RIVE_PLS_DIR
|
||||
premake5 --config=$1 --out=out/iphoneos_$1 --arch=universal --scripts=$RIVE_RUNTIME_DIR/build --file=premake5_pls_renderer.lua --no-rive-decoders --os=ios gmake2
|
||||
premake5 --config=$1 --out=out/iphoneos_$1 --arch=universal --scripts=$RIVE_RUNTIME_DIR/build --file=premake5_pls_renderer.lua --no-rive-decoders --os=ios gmake2
|
||||
make -C out/iphoneos_$1 clean
|
||||
make -C out/iphoneos_$1 -j12 rive_pls_renderer
|
||||
popd
|
||||
@@ -86,6 +86,7 @@ build_runtime_sim() {
|
||||
# Build rive_cg_renderer.
|
||||
pushd $RIVE_RUNTIME_DIR/cg_renderer
|
||||
premake5 --config=$1 --out=out/iphonesimulator_$1 --arch=universal --scripts=$RIVE_RUNTIME_DIR/build --os=ios --variant=emulator gmake2
|
||||
|
||||
make -C out/iphonesimulator_$1 clean
|
||||
make -C out/iphonesimulator_$1 -j12 rive_cg_renderer
|
||||
popd
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
path=`readlink -f "${BASH_SOURCE:-$0}"`
|
||||
DEV_SCRIPT_DIR=`dirname $path`
|
||||
path=$(readlink -f "${BASH_SOURCE:-$0}")
|
||||
DEV_SCRIPT_DIR=$(dirname $path)
|
||||
|
||||
$DEV_SCRIPT_DIR/build.skia.sh -a x86
|
||||
$DEV_SCRIPT_DIR/build.skia.sh -a x86
|
||||
$DEV_SCRIPT_DIR/build.skia.sh -a x64
|
||||
$DEV_SCRIPT_DIR/build.skia.sh -a arm
|
||||
$DEV_SCRIPT_DIR/build.skia.sh -a arm64
|
||||
@@ -12,4 +12,4 @@ $DEV_SCRIPT_DIR/build.skia.sh -a iossim_arm64
|
||||
$DEV_SCRIPT_DIR/build.skia.macos.sh -a arm64
|
||||
$DEV_SCRIPT_DIR/build.skia.macos.sh -a x64
|
||||
|
||||
$DEV_SCRIPT_DIR/build.rive.sh $@
|
||||
$DEV_SCRIPT_DIR/build.rive.sh $@
|
||||
|
||||
Submodule submodules/rive-cpp updated: 6fcc4fa7c9...6276d83854
Reference in New Issue
Block a user