How can I play this function in background services in flutter?
Kindly elaborate or also attach documentation or video link if possible.
I'm trying to play some music from a dependency named assets_audio_player.
I tried to use the didAppLifeCycleChange but in this way, I was facing a new
issuer it plays 2 songs. now I want to play songs directly in the background does not matter
app is in background or in foreground
void setupPlaylist() async {
await audioplayer.open(
showNotification: true,
Playlist(audios: [
Audio(
'assets/1.mp4',
metas: Metas(
title: "Bazz aa by YS",
artist: 'Talha',
image: const MetasImage.network(
'https://www.musicgrotto.com/wp-content/uploads/2021/09/best-songs-of-all-time-graphic-art.jpg'),
),
),
// Audio(SongsList[2].,
// metas: Metas(
// title: "Bazz01",
// artist: 'Talha',
// )),
Audio.network(
'https://audio-ssl.itunes.apple.com/itunes-assets/AudioPreview125/v4/09/17/bb/0917bbe1-58c3-6252-d00e-9b70d42ef5dc/mzaf_2269500085377778268.plus.aac.p.m4a',
metas: Metas(
id: 'Online',
title: 'Online',
artist: 'Florent Champigny',
album: 'OnlineAlbum',
// image: MetasImage.network('https://www.google.com')
image: const MetasImage.network(
'https://i.dawn.com/large/2021/09/61399fb500900.png'),
),
),
Audio(
'assets/2.mp4',
metas: Metas(
title: "Bazz aa by YS",
artist: 'Talha',
image: const MetasImage.network(
'https://www.musicgrotto.com/wp-content/uploads/2021/09/best-songs-of-all-time-graphic-art.jpg'),
),
),
Audio('assets/3.mp4',
metas: Metas(
title: "Bazz aa song",
artist: 'Talha',
image: const MetasImage.network(
'https://www.thenews.com.pk/assets/uploads/updates/2021-12-27/920292_6757937_hgjhj_updates.jpg'),
)),
Audio('assets/1.mp4',
metas: Metas(
title: "Bazz03",
artist: 'Talha',
image: const MetasImage.network(
'https://www.thenews.com.pk/assets/uploads/updates/2021-12-27/920292_6757937_hgjhj_updates.jpg'),
)),
]),
autoStart: true,
loopMode: LoopMode.playlist,
);
}
I'm pulling my hairs here. I have a Google Assistant application that I build with Jovo 4 and Google Actions Builder.
The goal is to create a HelpScene, which shows some options that explain the possibilities/features of the app on selection.
This is the response I return from my Webhook. (This is Jovo code, but doesn't matter as this returns a JSON when the Assistant calls the webhook.)
#Handle(GoogleAssistantHandles.onScene('HelpScene'))
showHelpList() {
return this.$send({
platforms: {
googleAssistant: {
nativeResponse: {
scene: {
name: this.jovo.$googleAssistant?.$request.scene?.name,
slots: {},
next: {
name: 'MainScene',
},
},
session: {
id: 'session_id',
languageCode: 'nl-BE',
params: {},
typeOverrides: [
{
name: 'prompt_option',
synonym: {
entries: [
{
name: 'ITEM_1',
synonyms: ['Item 1', 'First item'],
display: {
title: 'Item #1',
description: 'Description of Item #1',
image: {
alt: 'Google Assistant logo',
height: 0,
url: 'https://developers.google.com/assistant/assistant_96.png',
width: 0,
},
},
},
{
name: 'ITEM_2',
synonyms: ['Item 2', 'Second item'],
display: {
title: 'Item #2',
description: 'Description of Item #2',
image: {
alt: 'Google Assistant logo',
height: 0,
url: 'https://developers.google.com/assistant/assistant_96.png',
width: 0,
},
},
},
{
name: 'ITEM_3',
synonyms: ['Item 3', 'Third item'],
display: {
title: 'Item #3',
description: 'Description of Item #3',
image: {
alt: 'Google Assistant logo',
height: 0,
url: 'https://developers.google.com/assistant/assistant_96.png',
width: 0,
},
},
},
{
name: 'ITEM_4',
synonyms: ['Item 4', 'Fourth item'],
display: {
title: 'Item #4',
description: 'Description of Item #4',
image: {
alt: 'Google Assistant logo',
height: 0,
url: 'https://developers.google.com/assistant/assistant_96.png',
width: 0,
},
},
},
],
},
typeOverrideMode: 'TYPE_REPLACE',
},
],
},
prompt: {
override: false,
content: {
collection: {
items: [
{
key: 'ITEM_1',
},
{
key: 'ITEM_2',
},
{
key: 'ITEM_3',
},
{
key: 'ITEM_4',
},
],
subtitle: 'List subtitle',
title: 'List title',
},
},
firstSimple: {
speech: 'This is a list.',
text: 'This is a list.',
},
},
},
},
},
});
I created a HelpScene which pulls my options from my webhook.
In my slot filling, this is the configuration.
When I use the simulator, the options from my webhook are shown perfectly.
But when I click an item in the list, the app just stops working. "YourApp is currently not responding".
At first I thought it had something to do with my webhook, so I changed the behaviour of the "on slot is filled" condition, that it should prompt something, directly from Google Actions Builder, but the behaviour is still not desired: the app just stops working.
Any ideas what I'm doing wrong?
Thanks in advance!
Okay, after days of searching, I finally figured it out.
It did have something to do with the Jovo framework/setup and/or the scene parameter in the native response.
This is my component, in which I redirect new users to the HelpScene. This scene should show multiple cards in a list/collection/whatever on which the user can tap to receive more information about the application's features.
#Component()
export class WelcomeComponent extends BaseComponent {
async START(): Promise<void> {
const isNewUser = true;
if (isNewUser && this.$device.supports(Capability.Screen)) {
return this.$send(NextSceneOutput, {
name: 'HelpScene',
message: 'Hi, I noticed you are a new user, let me walk you through some options.',
});
}
return this.$send('Welcome!');
}
#Handle(GoogleAssistantHandles.onScene('HelpScene'))
help() {
const sessionData = this.$request.getSession();
if (sessionData && sessionData.prompt_option) {
return this.$send(NextSceneOutput, {
name: 'MainScene',
message: `You picked option ${sessionData.prompt_option}. This is some info about it ... What do you want to do now?`,
});
}
return this.$send({
platforms: {
googleAssistant: {
nativeResponse: {
session: {
id: 'session_id',
languageCode: '',
params: {},
typeOverrides: [
{
name: 'HelpOptionType',
typeOverrideMode: 'TYPE_REPLACE',
synonym: {
entries: [
{
name: 'ITEM_1',
synonyms: ['Item 1', 'First item'],
display: {
title: 'Item #1',
description: 'Description of Item #1',
image: {
alt: 'Google Assistant logo',
height: 0,
url: 'https://developers.google.com/assistant/assistant_96.png',
width: 0,
},
},
},
{
name: 'ITEM_2',
synonyms: ['Item 2', 'Second item'],
display: {
title: 'Item #2',
description: 'Description of Item #2',
image: {
alt: 'Google Assistant logo',
height: 0,
url: 'https://developers.google.com/assistant/assistant_96.png',
width: 0,
},
},
},
{
name: 'ITEM_3',
synonyms: ['Item 3', 'Third item'],
display: {
title: 'Item #3',
description: 'Description of Item #3',
image: {
alt: 'Google Assistant logo',
height: 0,
url: 'https://developers.google.com/assistant/assistant_96.png',
width: 0,
},
},
},
{
name: 'ITEM_4',
synonyms: ['Item 4', 'Fourth item'],
display: {
title: 'Item #4',
description: 'Description of Item #4',
image: {
alt: 'Google Assistant logo',
height: 0,
url: 'https://developers.google.com/assistant/assistant_96.png',
width: 0,
},
},
},
],
},
},
],
},
prompt: {
override: false,
content: {
list: {
items: [
{
key: 'ITEM_1',
},
{
key: 'ITEM_2',
},
{
key: 'ITEM_3',
},
{
key: 'ITEM_4',
},
],
subtitle: 'List subtitle',
title: 'List title',
},
},
firstSimple: {
speech: 'This is a list.',
text: 'This is a list.',
},
},
},
},
},
});
}
// ...other intents...
In AoG I made 2 scenes, 1 MainScene on which a user enters the app and one HelpScene, which looks like this (yaml config). The goal of the HelpScene is only to be used for slot filling on the different options, then a user should go back to the MainScene.
"conditionalEvents":
- "condition": "scene.slots.status == \"FINAL\""
"handler":
"webhookHandler": "Jovo"
"slots":
- "commitBehavior":
"writeSessionParam": "prompt_option"
"name": "prompt_option"
"promptSettings":
"initialPrompt":
"webhookHandler": "Jovo"
"required": true
"type":
"name": "HelpOptionType"
As you can see in my help() method, I just check if the session param is filled out. If it is, I redirect the user to the MainScene, but first give a response about the chosen option.
final List <Category> _categories = [
Category(
id: '1',
title: 'Poultry',
food: [
Food(
id: '1',
title: 'Chicken 1',
description: "qdwwqd",
price: 500.00,
image: "https://jb-ph-cdn.tillster.com/menu-images/prod/45df1872-c7f7-4b3d-baa9-1b0c4f56a5cc.png",
choice: [],
),
],
),
Category(
id: '2',
title: 'Vegetables',
food: [
Food(
id: '1',
title: 'Cabbage',
description: "qdwwqd",
price: 500.00,
image: "https://jb-ph-cdn.tillster.com/menu-images/prod/45df1872-c7f7-4b3d-baa9-1b0c4f56a5cc.png",
choice: [],
),
],
),
]
'''
In order to insert new data into the food array, first you need to find the correct category:
String myID = '1';
int index = _categories.indexWhere((cat) => cat.id == myID);
Once you did that, it is quite simple:
_categories[index].food.add(Food());
Good Morning,
I have some problem when I attempted to fill my Grid panel from my web service, the result was an empty grid, thank you for advance.
// Create store
var myStore = new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
url: 'Service.asmx/GetPeople',
headers: {
'Content-type': 'application/json'
}
}),
root: 'd',
id: 'Id',
fields: ['Id', 'FistName', 'LastName', 'BirthDate'],
autoLoad: true
});
//Create grid to display data from store
var gridTest = new Ext.grid.Panel({
store: myStore, // Our store
renderTo: Ext.getBody(),
forceFit: true,
columns: [ // Grid columns
{ xtype: 'gridcolumn', width: 100, text: 'Id', dataIndex: 'Id', flex: 1 },
{ xtype: 'gridcolumn', width: 100, text: 'Nom', dataIndex: 'FirstName', flex: 1 },
{ xtype: 'gridcolumn', width: 100, text: 'Mail', dataIndex: 'LastName', flex: 1 },
{ xtype: 'gridcolumn', width: 100, text: 'Phone', dataIndex: 'BirthDate', flex: 1 }
]
});
and this is my viewport:
Ext.create('Ext.container.Viewport', {
layout: "border",
items: [{
region: "north",
height: 50,
title: "Nord"
}, {
region: "south",
height: 200,
title: "sud",
bodyStyle: 'background: #fffff;',
border: false
}, {
region: "center",
title: "centre",
bodyStyle: 'background: #00000;',
border: false,
items: gridTest
}, {
region: "west",
width: 100,
title: "ouest"
}, {
region: "east",
width: 100,
title: "est"
}]
});
and this is RESPONSE FROM FIREBUG MOZILLA FIREFOX:
{"d": [{
"__type":"WebService4ExtJS.Model.Person",
"Id":0,
"FirstName":"sami",
"LastName":"samibizani#gmail.com",
"BirthDate":"23188219"
}, {
"__type":"WebService4ExtJS.Model.Person",
"Id":1,"FirstName":"admin",
"LastName":"admin#gmail.com",
"BirthDate":"1111111"
}, {
"__type":"WebService4ExtJS.Model.Person",
"Id":2,
"FirstName":"user",
"LastName":"user#gmail.com",
"BirthDate":"2222222"
}]
}
Your Store reader is not defined:
reader: {
type: 'json',
root: 'd',
idProperty: 'Id'
}
You can find the working code here.
And one little mistake: in the fields array, you wrote FistName instead of FirstName.
var settingForm = Ext.create('Ext.form.Panel', {
frame: false,
bodyStyle: 'padding:5px 5px 0',
modal: true,
resizable: false,
draggable: true,
forceSelection: true,
fieldDefaults: {
labelAlign: 'right',
//msgTarget: 'side',
labelWidth: 140
},
items: [{
xtype: 'fieldset',
anchor: '100%',
title: 'Some Information',
layout: 'column',
items: [{
xtype: 'container',
columnWidth: .5,
layout: 'anchor',
items: [{
xtype: 'hiddenfield',
name: 'txtHiddenId',
id: 'txtHiddenId'
}, {
xtype: 'textfield',
fieldLabel: 'Host Name',
name: 'txtHostName',
id: 'txtHostNameId',
allowBlank: false,
anchor: '96%',
disabled: true,
enableKeyEvents: true,
listeners: {
keypress: function() {
manageUpdate();
},
specialkey: function(field, e) {
if (e.getKey() == "46" || e.getKey() == "8")
manageUpdate();
}
}
}
Remove draggable: true and forceSelection: true. See if it helps.