I am working on creating a custom play/pause button for my audio elements, and here is how I have implemented it:
<div v-for="(post, p) in post_list">
<!-- ... -->
<!-- ... -->
<!-- ... -->
<v-avatar v-if="!is_played" color="#663399" size="42" class="mx-2"
@click="playMe('custom-wave-aud-'+p)"> <!-- is_played = true -->
<v-icon dark> mdi-play </v-icon>
</v-avatar>
<v-avatar v-if="is_played" color="#663399" size="42" class="mx-2"
@click="pauseMe('custom-wave-aud-'+p)"> <!-- is_played = false-->
<v-icon dark> mdi-pause </v-icon>
</v-avatar>
</div>
When the above code is executed, it switches between the pause icon and play icon when clicked. However, the issue arises as it affects all play/pause buttons for all items due to is_played
being assigned globally.
I aim to make is_played
impact only one item and be exclusive to the particular item where I toggle the play/pause button.
UPDATE: For reference, here is the play/pause function
playMe(c, index) {
document.getElementsByClassName(c)[0].play();
this.is_played = true;
},
pauseMe(c, index) {
document.getElementsByClassName(c)[0].pause();
this.is_played = false;
},