package EPrints::Plugin::MePrints::Widget::Video; use EPrints::Plugin::MePrints::Widget; @ISA = ( 'EPrints::Plugin::MePrints::Widget' ); use strict; sub new { my( $class, %params ) = @_; my $self = $class->SUPER::new( %params ); if ( !$self->{session} ) { $self->{session} = $self->{processor}->{session}; } $self->{name} = "EPrints Profile System: User Video Widget"; $self->{visible} = "all"; $self->{advertise} = 1; $self->{render_title} = 0; $self->{show_in_controls} = 0; $self->{surround} = "Simple"; return $self; } sub render_content { my( $self ) = @_; if ( $self->{user}->{dataset}->has_field( "profile_video" ) && $self->{user}->{dataset}->has_field( "rights_to_video" ) && defined $self->{user}->get_value("profile_video") && defined $self->{user}->get_value("rights_to_video") && $self->{user}->get_value("rights_to_video") eq "TRUE" ) { my $video_url = $self->{user}->get_value("profile_video"); my @parts = split( /&/, $video_url ); my $video_id; if ( $parts[0] =~ m/http:\/\/www\.youtube\.com\/watch\?v=(.+)/) { $video_id = $1; } if (defined $video_id) { return $self->{session}->make_element( "iframe", align => "center", frameborder => 1, marginheight => 2, marginwidth => 2, name => "User Profile Video", scrolling => "auto", width => "420", height => "315", src => "http://www.youtube.com/embed/$video_id", allowfullscreen => 1, ); } else { return $self->{session}->make_text( "It has not been possible to embed this video - please check that the URL is of the form: http://www.youtube.com/watch?v=ZnehCBoYLbc" ); } } else { #return $self->{session}->make_element( "div" ); } } 1;