0
votes

I am working in xamarin forms. I am trying to play video in Video Player. For the same I have used this sample code from github

https://github.com/xamarin/customer-success-samples/tree/master/samples/Xamarin.Forms/FormsNativeVideoPlayer

but problem is when I put "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" link to VideoPlayer_CustomRender.cs file Video is play properly. but when I put any youtube link this is not working and show me the error "Can't play this video". I want to achieve this functionality specially in android.

I can't understand what is happening?

3

3 Answers

2
votes

You can check out the video player component on the Xamarin Forms component store. It allows you to render the native video player on iOS, Android, and Windows Phone.

It also allows you to play YouTube videos using an included XAML extension called YouTubeVideoIdExtension. Note that this is experimental since you should be using the official Google APIs to integrate and get the correct source URLs.

The code snippet below shows the simplest example of just dropping it in and using it. You also have the ability to hook into events like playing, paused, stopped, completed, etc. You can control volume, autoplay, and repeat among other things.

https://github.com/adamfisher/Xamarin.Forms.VideoPlayer

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:o="clr-namespace:Octane.Xam.VideoPlayer;assembly=Octane.Xam.VideoPlayer"
             x:Class="VideoPlayerSamples.VideoPlayerBasicExamplePage"
             Title="Basic Video Player">

    <o:VideoPlayer Source="http://vjs.zencdn.net/v/oceans.mp4" />

</ContentPage>

Disclaimer: This is my component.

0
votes

Have a look at LibVLCSharp. Free and opensource.

Disclaimer: I am the maintainer.

-2
votes

I know I am a little late but I don't see any one state that the issue is all in the link you are using, you need a direct link, direct link usually ends in the video file name(like your example that works). And if you paste it on your web browser it should just download the file and not take you to a specific site, if it does take you to a site like Youtube then it isn't a direct download link.

Example of an Img - https://i.postimg.cc/0QHpqpVr/1-Waffle-Fry-Cooked.jpg