Robby
Posts: 0
Joined: Wed Jun 25, 2014 2:21 pm

How to set video-id property of youtube player dynamically

I have a dynamic video list based on a database. The data attribute 'data-video-id' of each list item is bound to a field videoId in the database.
I want to set the video-id based of the youtube player dynamically when the user clicks on a list item.

Is it possible to do this with an event action 'set property' ? How can I specify the data attribute 'data-video-id' of the selected list item ?

Or do I need to use the event action 'run javascript' ? How can I access the video-id property in javascript ?

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

How to set video-id property of youtube player dynamically

Hello Robby,

'data-video-id' is not a standard property/attribute for list item. Do you put it via js? Then you should refer to it from js. You should add run javascript action on event Click on the list item.
In the js code variable this indicates to list item on which triggered the event. To get property/attribute you should use the appropriate method of jquery http://api.jquery.com/category/manipu...

Robby
Posts: 0
Joined: Wed Jun 25, 2014 2:21 pm

How to set video-id property of youtube player dynamically

Hi,

I used this javascript and it works but isn't it possible to set the video id property of the appery youtube component ?

Appery('youtubePlayer').attr('src', 'https://www.youtube.com/embed/' + $(this).attr('data-video-id'));

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

How to set video-id property of youtube player dynamically

Hi Robby,

Use the following code:preAppery('youtubePlayer').attr("data-video-id", videoId);/preWhere 'videoId' is a value of new ID.

EJLD
Posts: 0
Joined: Sun Jun 08, 2014 11:03 pm

How to set video-id property of youtube player dynamically

this shld help me.
thks

EJLD
Posts: 0
Joined: Sun Jun 08, 2014 11:03 pm

How to set video-id property of youtube player dynamically

Hi There,

I GET the videoID from the Appery DB.
but neither mapping link, nor the code work unfortunately.

always have the error msg from YouTube "an error occured, pls try again later".

it works only when I place the videoID in the property input field of the builder.

any idea ?

thk you,
Eric

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

How to set video-id property of youtube player dynamically

Hi Eric,

We are able to successfully map a value from database to video. Could you please post a screenshot of mapping? When and how do you run a service?

EJLD
Posts: 0
Joined: Sun Jun 08, 2014 11:03 pm

How to set video-id property of youtube player dynamically

thks for your prompt reply.
I don't know why it doesn't work, if it works with you.
it seems so simple.
let me check again and send you some details.
Eric

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

How to set video-id property of youtube player dynamically

Hi Eric,

Thank you. Waiting for the result.

EJLD
Posts: 0
Joined: Sun Jun 08, 2014 11:03 pm

How to set video-id property of youtube player dynamically

Hi Kateryna, I cld manage to both youtube video working. it was a bit unrational but it works.
Best

Return to “Issues”