Page 1 of 2

Videos from Facebook or YouTube

Posted: Thu Apr 18, 2019 6:55 am
by EYUman
Hi there

I am looking for a way to make videos run on FlatPress .. until now, noting works.

Thanks in advance for any answer.
Regards
EYUman

Re: Videos from Facebook or YouTube

Posted: Sat Apr 20, 2019 11:20 am
by Arvid
Hi, welcome to the FlatPress support forum :)

I have no experiences with Facebook videos (anyone else?), but as for Youtube, it's as simple as that:

Code: Select all

[video=https://www.youtube.com/watch?v=mIGfest1b1M]
See also the BBCode documentation on our wiki: https://wiki.flatpress.org/doc:plugins:bbcode

Regards,
Arvid

Re: Videos from Facebook or YouTube

Posted: Sun Apr 21, 2019 10:25 am
by vodka
Replace the script from line 332 in fp-plugin/bbcode/plugin.bbcode.php with this

Code: Select all

function do_bbcode_video($action, $attr, $content, $params, $node_object) {
	if ($action == 'validate') {
		return true;
	}
	$vurl = parse_url($attr['default']);
	if (isset($attr['type'])) {
		$type = $attr['type'];
	} else {
		// is it http://www.MYSITE.com  or http://MYSITE.com ?
		$web = explode('.', $vurl['host']);
		array_pop($web);
		$type = isset($web[1])
			? $web[1]
			: $web[0];
	}
	
		$color = isset($attr['color'])
			? $attr['color']
			: '';
		$width = isset($attr['width'])
			? $attr['width']
			: '560';
		$height = isset($attr['height'])
			? $attr['height']
			: '315';
		$allowfs = isset($attr['allowfullscreen'])
			? $attr['height']
			: 'allowfullscreen';			
		$float = isset($attr['float'])
			? "align=\"{$attr['float']}\" "
			: "style=\"margin: 0 auto; display:block;\" ";

	
	$query = utils_kexplode($vurl['query'], '=&');
	$the_url = null;
	$others = '';
	switch ($type) {
		case 'html5':
			$the_url = "<video style=\"display:block; margin: 0 auto;\" width=\"{$width}\" height=\"{$height}\" controls>"
				."<source src=\"".$attr['default']."\">"
				."Your browser does not support the video tag."
				."</video>";
			break;
		case 'youtube':
			$the_url = "<iframe src=\"https://www.youtube.com/embed/{$query['v']}\" width=\"{$width}\" height=\"{$height}\" frameborder=\"0\" allow=\"accelerometer; autoplay; fullscreen; encrypted-media; gyroscope; picture-in-picture\" {$float}></iframe>";
			break;
		case 'vimeo':
			$vid = isset($query['sec'])? $query['sec'] : str_replace('/', '', $vurl['path']);
			$the_url="<iframe src=\"https://player.vimeo.com/video/{$vid}?color={$vid}&title=0&byline=0&portrait=0\" width=\"{$width}\" height=\"{$height}\" frameborder=\"0\" allow=\"autoplay; fullscreen;\" allowfullscreen {$float}></iframe>";
			break;
		case 'facebook':
			$vid = isset($query['sec'])? $query['sec'] : str_replace('/video/', '', $vurl['path']);
			$the_url="<div id=\"fb-root\"></div>
			<script async defer src=\"https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v3.2\"></script>
			<div class=\"fb-video\" data-href=\"{$vid}\" data-allowfullscreen=\"true\" data-width=\"{$width}\"></div>";
			break;
		case 'default':
		default:
			$the_url = null;
	}

	if ($the_url) {
		return $the_url;
	}
	return '[unsupported video]';
}
You have support for youtube, vimeo, facebook and html5 (for mp4 you must set the type like in the exemple).

Code: Select all

youtube:

[video=https://www.youtube.com/watch?v=15nPDcuqDTI]

html5:

[video=https://media.w3.org/2010/05/sintel/trailer.mp4 type=html5]

vimeo:

[video=https://vimeo.com/96867408]

facebook:

[video=https://www.facebook.com/facebook/videos/10153231379946729/]
I hope to find a way to auto recognize html5 videos and I will send all in github.

Re: Videos from Facebook or YouTube

Posted: Mon Jul 01, 2019 4:38 pm
by B-d-R-D
Hello there, hello vodka,

I replaced the script from line 332 in fp-plugin/bbcode/plugin.bbcode.php with your code and I got Error 500...
Nothing to see anymore behalve the Error 500 script error ..

Whats wong now?
I installed the flatpress-master which was offered here in an other thread .. :
Re: White screen after setup of Flatpress
Beitrag von Lubomír Ludvík » Mi Feb 20, 2019 9:05 pm

try dev version 1.1 https://github.com/flatpressblog/flatpr ... master.zip
And now I try to get my website running again ... :roll:

Well, I changed it back to the origin file, now the website is running again, but there is no possibility to run any other video URL than You Tube.

Regards
B-d-R-D

Re: Videos from Facebook or YouTube

Posted: Mon Jul 08, 2019 10:50 pm
by vodka
You must replace only the lines for the function (from 332 to 373)

Re: Videos from Facebook or YouTube

Posted: Sat Sep 21, 2019 6:05 pm
by rhays
Thanks, Vodka!

Modified code as stated, and works well. Thanks for the patch.

Rick

Re: Videos from Facebook or YouTube

Posted: Mon Oct 07, 2019 3:07 pm
by Arvid
Thank you vodka, this is very useful. I slightly adapted your code and added it to the FP sources.

To be mentioned: It does not support uploaded video files yet - please refer to the the Audio and video player plugin in this case. Maybe we could unify this later.

Re: Videos from Facebook or YouTube

Posted: Fri May 29, 2020 3:43 am
by Tongara
Arvid wrote: Mon Oct 07, 2019 3:07 pm To be mentioned: It does not support uploaded video files yet - please refer to the the Audio and video player plugin in this case. Maybe we could unify this later.
I've tried to use this plugin in the past, but no matter the URL of the audio all I get is an error saying "Given file does not exist.", when it 100% does. Any ideas?

Re: Videos from Facebook or YouTube

Posted: Mon Jun 01, 2020 2:35 pm
by Arvid
Did you enter the correct path to the file?

See this entry on my personal blog, where I included the video like this:

Code: Select all

[videoplayer="attachs/2018-06-30_haldehoheward.mp4" width="640" height="360"]
The "audioplayer" tag works the same way.

Do you have the "attachs" folder in your video path? (If that doesn't help, please give us the link to your site and to the audio file, so we can test it together.)

All the best,
Arvid

Re: Videos from Facebook or YouTube

Posted: Mon Jun 01, 2020 5:23 pm
by Tongara
Arvid wrote: Mon Jun 01, 2020 2:35 pm Did you enter the correct path to the file?

See this entry on my personal blog, where I included the video like this:

Code: Select all

[videoplayer="attachs/2018-06-30_haldehoheward.mp4" width="640" height="360"]
The "audioplayer" tag works the same way.

Do you have the "attachs" folder in your video path? (If that doesn't help, please give us the link to your site and to the audio file, so we can test it together.)

All the best,
Arvid
Ah, if everything needs to be in a certain folder then I'll just use regular HTML5 player code for playing files. Thanks anyway.