update media object programatically If I have the id of an existing piece of media content, what can I do to update it (modify it)?

I know how to create a new piece of media , (with Media::create) , but not sure of the code to load and then updated an existing piece of Media.

thanks
Media is like any other entity based on ContentEntityBase in Drupal.    

// top of your file
use Drupal\media_entity\Entity\Media;

// in a function
$media = Media::load($id);
// do stuff with $media
$media-&gt;save();


edit:

In a method of a class you would not want to use Media:: but instead use entityTypeManager service to load the entity:

$media = $this-&gt;entityTypeManager-&gt;getStorage('media')-&gt;load($id); where entityTypeManager is injected to your class.