1

I am using code:

moviePlayer = new MPMoviePlayerController(new NSUrl("https://www.youtube.com/watch?v=9SdF_1OrN0Y"));

moviePlayer.View.Frame = new RectangleF(10, 80, 300, 200);
            moviePlayer.View.BackgroundColor = UIColor.Clear;
            moviePlayer.SourceType = MPMovieSourceType.File;
            //moviePlayer.SetFullscreen(true,true);
            moviePlayer.Fullscreen = true;
            // Set this property True if you want the video to be auto played on page load
            moviePlayer.ShouldAutoplay = true;
            // If you want to keep the Video player on-ready-to-play state, then enable this
            // This will keep the video content loaded from the URL, untill you play it.
            moviePlayer.PrepareToPlay();
            // Enable the embeded video controls of the Video Player, this has several types of Embedded controls for you to choose
            moviePlayer.ControlStyle = MPMovieControlStyle.Default;
            View.AddSubview(moviePlayer.View);

After adding code

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
    <key>NSExceptionDomains</key>
    <dict>
        <key>clips.vorwaerts-gmbh.de</key>
        <dict>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSIncludesSubdomains</key>
            <true/>
        </dict>
    </dict>
</dict>

I am able to play video using below URL: http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4

How to play YouTube video coming in API response?

[
    {
        "VideoId": 1,
        "VideoTitle": "Selena Gomez testimony hillsong conference 2017",
        "VideoUrl": "https://www.youtube.com/watch?v=9SdF_1OrN0Y"
    }
]
halfer
  • 18,701
  • 13
  • 79
  • 158
Dev Maran
  • 41
  • 3
  • Youtube does not support "direct" embedded streams. There are non-official 3rd-party libraries available but they violate Google's TOS. You should review the official docs to see how to play Youtube videos within an embedded web view in your app: https://developers.google.com/youtube/v3/guides/ios_youtube_helper – SushiHangover Jan 31 '18 at 10:10
  • @sushihangover The below link provides a way to play youtube videos in ios app so I want the similar way to do this in Xamarin.iOS https://stackoverflow.com/questions/1779511/play-youtube-videos-with-mpmovieplayercontroller-instead-of-uiwebview – Dev Maran Jan 31 '18 at 11:14
  • Yes, most of those answers are using methods that violate Google s TOS, if that is what you want to do, use one of those existing answers, the one that doesn't is using a uiwebview just like the official docs show – SushiHangover Jan 31 '18 at 12:06
  • Please read [Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers?](//meta.stackoverflow.com/q/326569) - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions. – halfer Jan 31 '18 at 14:55

1 Answers1

0

if you are not able to play youtube url then you should have to use embed url of that video instead of youtube url Normal youtube url : https://www.youtube.com/watch?v=9SdF_1OrN0Y Embed youtube url : https://www.youtube.com/embed/9SdF_1OrN0Y

if you don't know how to convert youtube normal url to embed url then please refer this url Convert youtube url to iframe embed code

let me know if any query Happy coding :)

  • Thanks for the response.I am looking for sample code in C# like the second solution in URL: https://stackoverflow.com/questions/1779511/play-youtube-videos-with-mpmovieplayercontroller-instead-of-uiwebview – Dev Maran Feb 03 '18 at 09:43
  • Give me your solution i will modify it i will send you – lalit Maheshwari Feb 03 '18 at 09:53