Error of “Call a member function on non object” while var_dump get correct result

To me it seems Picture_Template is worthless – it’s not even correctly formed (you need to place run-time code in a constructor).

Plus you also seem to lack the basic understanding of variable scope (like accessing $post and $obj within functions and classes, without globalising them first).

Here is what I think you’re trying to do;

function test_picture()
{    
    $picture = new Picture( get_the_ID() );
    $picture_result = $picture->embed();

    /* debugging */
    echo '<pre>';
    var_dump( $picture );
    var_dump( $picture_result );
    echo '</pre>';
}

function play_button()
{
    echo get_play_button();
}

function get_play_button()
{
    $picture = new Picture( get_the_ID() );

    if ( $embed = $picture->embed() ) {
        // do something & return something
    }

    return null; // return nothing if embed failed
}