Skip to content

Problem to load asset on demand #16

@megajogos

Description

@megajogos

I'm currently trying to implement Assets delivery on demand in my application, but I'm not getting it to work. It's showing in logcat that the download was completed, but I'm not able to access the file inside the folder. Do you have an example of how to do this process?

Below is the structure I made in the app:
app.xml
<assetPacks> <assetPack id="audioAssetPack" delivery="on-demand" folder="audioAssetPack"/> </assetPacks>

My code:
`assetsOnDemand = new PlayAssetDelivery();
trace("!!!assets.initAssetDelivery() ", assetsOnDemand.initAssetDelivery())
if (assetsOnDemand.initAssetDelivery()){
assetsOnDemand.addEventListener(PlayAssetDeliveryEvent.PLAY_ASSET_UPDATE, playAssetDeliveryStatusHandler);
trace("!!!PlayAssetDelivery initialised");
trace("!!!PlayAssetDelivery initialised2", assetsOnDemand.fetchAssetPack("audioAssetPack"));
trace("!!!PlayAssetDelivery initialised3", assetsOnDemand.getAssetPackStatus("audioAssetPack"));
trace("!!!PlayAssetDelivery initialised6", assetsOnDemand.getAssetPackLocation("audioAssetPack"));
}

private function playAssetDeliveryStatusHandler(event):void {
trace( "asset pack name: " + event.assetPackName );
trace( "status: " + PlayAssetStatus.getStatus(event.status) ); // Value from PlayAssetStatus
trace( "location: " + assetsOnDemand.getAssetPackLocation("audioAssetPack"));
trace( "location2: " + assetsOnDemand.getAssetAbsolutePath("audioAssetPack", "audioAssetPack/sfx_peca_domino.mp3"));
trace( "location3: " + assetsOnDemand.getAssetAbsolutePath("audioAssetPack", "audioAssetPack\sfx_peca_domino.mp3"));
trace( "location4: " + assetsOnDemand.getAssetAbsolutePath("audioAssetPack", "sfx_peca_domino.mp3"));
trace( "location5: " + assetsOnDemand.getAssetAbsolutePath("audioAssetPack", "audioAssetPack"));
trace( "location6: " + assetsOnDemand.getAssetAbsolutePath("sfx_peca_domino.mp3", "audioAssetPack"));
trace( "location7: " + assetsOnDemand.getAssetAbsolutePath("audioAssetPack/sfx_peca_domino.mp3", "audioAssetPack"));
trace( "location8: " + assetsOnDemand.getAssetAbsolutePath("audioAssetPack\sfx_peca_domino.mp3", "audioAssetPack"));
}`

logcat output
2023-01-09 19:31:38.306 6368-6368/air.br.com.megajogos.mobile D/AppLovinAdapter: Requesting banner of size BANNER for zone: 757202f26f06f141 2023-01-09 19:31:38.363 6368-6368/air.br.com.megajogos.mobile I/air.br.com.megajogos.mobile: asset pack name: audioAssetPack 2023-01-09 19:31:38.363 6368-6368/air.br.com.megajogos.mobile I/air.br.com.megajogos.mobile: status: COMPLETED 2023-01-09 19:31:38.366 6368-6368/air.br.com.megajogos.mobile E/PlayCore: UID: [10264] PID: [6368] AssetPackStorage : Failed to find assets directory: /data/data/air.br.com.megajogos.mobile/files/assetpacks/audioAssetPack/119003029/119003029/assets 2023-01-09 19:31:38.366 6368-6368/air.br.com.megajogos.mobile I/air.br.com.megajogos.mobile: location: null 2023-01-09 19:31:38.370 6368-6368/air.br.com.megajogos.mobile E/PlayCore: UID: [10264] PID: [6368] AssetPackStorage : Failed to find assets directory: /data/data/air.br.com.megajogos.mobile/files/assetpacks/audioAssetPack/119003029/119003029/assets 2023-01-09 19:31:38.370 6368-6368/air.br.com.megajogos.mobile I/air.br.com.megajogos.mobile: location2: null 2023-01-09 19:31:38.373 6368-6368/air.br.com.megajogos.mobile E/PlayCore: UID: [10264] PID: [6368] AssetPackStorage : Failed to find assets directory: /data/data/air.br.com.megajogos.mobile/files/assetpacks/audioAssetPack/119003029/119003029/assets 2023-01-09 19:31:38.374 6368-6368/air.br.com.megajogos.mobile I/air.br.com.megajogos.mobile: location3: null 2023-01-09 19:31:38.377 6368-6368/air.br.com.megajogos.mobile E/PlayCore: UID: [10264] PID: [6368] AssetPackStorage : Failed to find assets directory: /data/data/air.br.com.megajogos.mobile/files/assetpacks/audioAssetPack/119003029/119003029/assets 2023-01-09 19:31:38.378 6368-6368/air.br.com.megajogos.mobile I/air.br.com.megajogos.mobile: location4: null 2023-01-09 19:31:38.382 6368-6368/air.br.com.megajogos.mobile E/PlayCore: UID: [10264] PID: [6368] AssetPackStorage : Failed to find assets directory: /data/data/air.br.com.megajogos.mobile/files/assetpacks/audioAssetPack/119003029/119003029/assets 2023-01-09 19:31:38.383 6368-6368/air.br.com.megajogos.mobile I/air.br.com.megajogos.mobile: location5: null 2023-01-09 19:31:38.385 6368-6368/air.br.com.megajogos.mobile I/air.br.com.megajogos.mobile: location6: null 2023-01-09 19:31:38.387 6368-6368/air.br.com.megajogos.mobile I/air.br.com.megajogos.mobile: location7: null 2023-01-09 19:31:38.390 6368-6368/air.br.com.megajogos.mobile I/air.br.com.megajogos.mobile: location8: null 2023-01-09 19:31:38.417 6368-6368/air.br.com.megajogos.mobile I/air.br.com.megajogos.mobile: asset pack name: audioAssetPack

my project structure
Captura

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions