I'm adding a custom video encoding element to a buddypress site, so that all users, if they upload videos that are not in mpeg format, the videos will be sent to an encoding script to be put into mpeg4 format.
Once the site detects that a video is in non mpeg4 format, an ajax call asks firstly 1) if the video has been sent over already, and 2) if it hasn't, sends it to the script to be encoded, and adds a piece of activity metadata to say that it has been sent.
The idea behind this is while the video is processing, it will check to see if that metadata exists and has a value of 1. If it does, it won't send the video over again.
So in the course of writing this, I wrote the following if statement with custom metadata to be added.
$encodedId = bp_activity_get_meta( $activityId, '_mpp_video_encode');
if($encodedId != 1) {
// execute a bash script to convert the video
// when done, create metadata set that metadata to 1
bp_activity_add_meta( $activityId, '_mpp_video_encode', 1, true );
}
else {
// do nothing, video is being encoded
}
When I was first testing this out, it added the metadata successfully and triggered everything I was looking for. I then deleted the metadata in the backend using phpmyadmin to run the script again for testing.
Now, no matter what I do, the function bp_activity_get_meta always returns a value of 1, and so then the script won't run, even though I can see clearly in the database through phpmyadmin that this simply isn't true.
As far as I can tell, bp_activity_add_meta does not create entries anywhere else in the database but bp_activity_meta.
Help!!