Video won't play if age restriction is in place

Feb 14, 2013 at 7:54 PM
Edited Feb 14, 2013 at 7:55 PM
Hi,

Video won't play in 1.11.0 if the video requires user to sign in due to age content warning.

http://www.youtube.com/watch?v=liLU2tEz7KY

Edit: When trying to play the video, I get "videos_not_found" error (other videos play fine after the update to 1.11.0).

Is there any way around this?

Regards,

Casey
Coordinator
Feb 14, 2013 at 9:08 PM
The YouTube class downloads the YouTube page and extracts the MP4 links. If there is a content warning, the MP4 links cannot be found. If you find a solution to avoid this content warning and directly access the YouTube page, the problem can be fixed... Until now I haven't found a solution...
Feb 15, 2013 at 10:20 AM
OK, thank you. For now, I have put an if command around it and will instead open that particular video in the browser.

The odd thing is that on the ERBoH page they have embedded the video and it plays fine without logging in.

http://epicrapbattlesofhistory.com/

I'll see if I can find a way round it and let you know.

Casey
Feb 15, 2013 at 10:22 AM
You can actually get around the restriction using the full screen mode

http://youtube.googleapis.com/v/liLU2tEz7KY

But I don't know if you can get the mp4 file that way?
Coordinator
Feb 15, 2013 at 11:26 AM
This won't work as these links serve a flash video, and not a html page with the MP4 links in it... we need another way...
Coordinator
Feb 15, 2013 at 2:29 PM
To work around this issue we eventually have to find a completely other way to get the MP4 links... maybe parsing the SVG flash file? Does someone know how other YouTube apps find these MP4 links?
Jun 19, 2013 at 9:01 AM
will this example code work to by pass age restriction is in place
var url = decodeURIComponent( window.location.search.match( /[^?&]*next_url=([^&]*)/ )[1] );
if( url && url.match( /^\/|(https?:\/\/(www\.)?youtube\.com\/)/ ) && document.getElementById( "verify" ) ) {
 GM_xmlhttpRequest({
  method: "GET",
  headers: {
   "User-Agent": "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
  },
  url: url,
  onload: function( response ) {
   if ( response.status == 200 ) {
    if( response.finalUrl.match( "/verify_controversy" ) ) {
     window.location.href = url + "&skipcontrinter=1";
    } else {
     document.open( "text/html", "replace" );
     document.write( response.responseText );
     document.close();
    }
   }
  }
 });
}
Coordinator
Jun 19, 2013 at 9:04 AM
Setting the google bot user-agent bypasses the age check?
Coordinator
Jun 19, 2013 at 9:47 AM
It really works. Thanks a lot.
Changes are now in SVN (NuGet package coming later...)
Jun 19, 2013 at 10:44 AM
thanks for the update i am looking for a winrt video play which can play mytoolkit video which can show the buffering process,

what happens is my media play stops playing the video after some time and the video time line gos back to 0.0.0,I think the buffering stops because of low bandwidth,but if i add a direct source url to it play till the end,Any helps how to solve it
Coordinator
Jun 19, 2013 at 12:51 PM
In WinRT there is only the method GetVideoUriAsync, there is no buffering implementation... haven't you found something in the internet as the buffering implementation is independent from the uri retrieval...
Jun 19, 2013 at 1:55 PM
Edited Jun 19, 2013 at 4:20 PM
this is my first app using mytoolkit

http://apps.microsoft.com/windows/app/woody-woodpecker/73c9f2b9-2938-497a-a31c-0e3e65b84aa7

check it play the YouTube video but it stops playing after some time i think it is because of the slow buffering rate in my network the YouTube video stops playing after some time and the source two is from my server.

I have to write a code to reseek from the position where the buffering has stopped

``` using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.UI.Xaml.Media.Imaging;
using MyToolkit.Multimedia;

namespace Woody_Woodpecker
{
public sealed partial class VideoPage : Page
{
    int j = 0, i = 0;
    DispatcherTimer ticks = new DispatcherTimer();
    DispatcherTimer dispatcherTimer = new DispatcherTimer();

    public VideoPage()
    {
        dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 1, 0);
        dispatcherTimer.Tick += dispatcherTimer_Tick;
        this.InitializeComponent();
        controlhide.Begin();
        BitmapImage ab = new BitmapImage();
        ab.UriSource = new Uri("ms-appx:///Assets/Media-Pause.png");
        playbutton.Source = ab;
        media1.Volume = 100;
        volumeslied.Value = 50;
    }


    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        var item = (Node)e.Parameter;
         textBlock.Text = "watching now:" + item.title;
          yvideo.Text = item.yvideo;
        video.Text = item.video;         
        VID();
    }

    async void VID()
    {
        try
        {
            var url = await YouTube.GetVideoUriAsync(yvideo.Text);         

            media1.Source = url.Uri;             
        }
        catch
        {
            media1.Source = new Uri(video.Text);              

        }

    }

    private void Back(object sender, TappedRoutedEventArgs e)
    {
        this.Frame.GoBack();
    }


    private int counter;
    public int Counter
    {
        get { return counter; }
        set
        {
            counter = value;
            //OnPropertyChanged("Counter");
        }
    }


    private void dispatcherTimer_Tick(object sender, object e)
    {
        Counter++;
        if (Counter == 5)
        {
            dispatcherTimer.Stop();
            counter = 0;
                  }
    }

    void ticks_Tick(object sender, object e)
    {

        durationSlider.Value = media1.Position.TotalMilliseconds;
        MediaCurrentPosition.Text = media1.Position.Hours
                                + ":" + media1.Position.Minutes
                                + ":" + media1.Position.Seconds;          

    }

    private void SeekToMediaPosition(object sender, RangeBaseValueChangedEventArgs e)
    {
        int slidervalue = (int)durationSlider.Value;
        TimeSpan ts = new TimeSpan(0, 0, 0, 0, slidervalue);
        media1.Position = ts;
    }

    private void PlayButton_Click(object sender, TappedRoutedEventArgs e)
    {
        if (j == 0)
        {
            BitmapImage ab = new BitmapImage();
            ab.UriSource = new Uri("ms-appx:///Assets/Media-Play.png");
             playbutton.Source = ab;
            media1.Pause();
            j = 1;
            controlhide.Stop();
            controlhide1.Stop();
        }
        else
        {
            if (media1.DefaultPlaybackRate == 0)
            {
                BitmapImage ab = new BitmapImage();
                ab.UriSource = new Uri("ms-appx:///Assets/Media-Pause.png");
                     playbutton.Source = ab;
                media1.DefaultPlaybackRate = 1.0;
                media1.PlaybackRate = 1.0;
                media1.Play();
                j = 0;
                controlhide.Begin();
                controlhide1.Stop();

            }

          BitmapImage ab1 = new BitmapImage();
            ab1.UriSource = new Uri("ms-appx:///Assets/Media-Pause.png");
             playbutton.Source = ab1;
            media1.Play();
            j = 0;
            controlhide.Begin();
            controlhide1.Stop();
        }
    }

    private void PauseButton_Click(object sender, TappedRoutedEventArgs e)
    {
        media1.Pause();
    }

    private void StopButton_Click(object sender, TappedRoutedEventArgs e)
    {
        media1.Stop();
    }

    private void RewindButton_Click(object sender, RoutedEventArgs e)
    {
        media1.DefaultPlaybackRate -= 1.5;
        media1.Pause();
        media1.Play();
    }
    private void gridentered(object sender, PointerRoutedEventArgs e)
    {
        controlhide.Begin();
    }
    private void grridecxited(object sender, PointerRoutedEventArgs e)
    {
        controlhide.Stop();
    }
    private void volumeslied_ValueChanged(object sender, RangeBaseValueChangedEventArgs e)
    {
        media1.Volume = volumeslied.Value;
    }
    private void durationSlider_DragLeave(object sender, DragEventArgs e)
    {
        media1.Position = TimeSpan.FromSeconds(durationSlider.Value);
    }

    private void durationSlider_PointerPressed(object sender, PointerRoutedEventArgs e)
    {
        media1.Position = TimeSpan.FromSeconds(durationSlider.Value);
    }

    private void durationSlider_ValueChanged(object sender, RangeBaseValueChangedEventArgs e)
    {
        int slidervalue = (int)durationSlider.Value;
        TimeSpan ts = new TimeSpan(0, 0, 0, 0, slidervalue);
        media1.Position = ts;
    }

    private void media_BufferingProgressChanged(object sender, RoutedEventArgs e)
    {
        double ad = media1.BufferingProgress * 100;
    }

       private void media_MediaOpened(object sender, RoutedEventArgs e)
    {
        durationSlider.Maximum = media1.NaturalDuration.TimeSpan.TotalMilliseconds;
        ticks.Interval = TimeSpan.FromMilliseconds(1);
        ticks.Tick += ticks_Tick;
        ticks.Start();
        MediaDuration.Text = media1.NaturalDuration.ToString().Substring(0, 8);
        dispatcherTimer.Tick += dispatcherTimer_Tick;
        dispatcherTimer.Start();
    }

    private void volume_Tapped(object sender, TappedRoutedEventArgs e)
    {
        if (j == 0)
        {
            BitmapImage ab = new BitmapImage();
            ab.UriSource = new Uri("ms-appx:///Assets/Wrong.png");
            volumeslied.IsEnabled = false;
            volume.Source = ab;
            media1.IsMuted = true;
            j = 1;
        }
        else
        {
            BitmapImage ab = new BitmapImage();
            ab.UriSource = new Uri("ms-appx:///Assets/SpeakerVolume.png");
            volumeslied.IsEnabled = true;
            volume.Source = ab;
            media1.IsMuted = false;
            j = 0;
        }
    }
    private void grridecxited(object sender, RightTappedRoutedEventArgs e)
    {
        if (j == 0)
        {    controlhide.Stop();
            controlhide1.Stop();
            j = 1;
        }
        else
        {
            controlhide1.Begin();
            j = 0;
        }
    }
Coordinator
Jun 19, 2013 at 2:00 PM
Have you tried to use the player framework (https://playerframework.codeplex.com/)? Maybe it supports buffering... I think a code to reseek from the position where the buffering has stopped is not a good solution... (?) Maybe you can pause the playback instead of resetting it to 0:0:0?
Jun 19, 2013 at 2:26 PM
Thanks this perfect to stream YouTube videos there is not seek problem.
Coordinator
Jun 19, 2013 at 2:29 PM
Edited Jun 19, 2013 at 2:29 PM
So it is now working? (then ill use this framework as recommendation for YT WinRT playback).
Jun 19, 2013 at 4:10 PM
ya it dos not have low bandwidth streaming problem.Works perfectly.
Sep 9, 2013 at 7:04 AM
How did you use the MS Player Framwork to prevent buffering?
If i unse this framework with the player framework and set the quality on 1080p it will buffer eventually on a slow connection.
Oct 10, 2013 at 1:41 AM
Did the code changes for this go live in NuGet? I have 1.24 and am having an issue with one video in particular(that I have found).

https://www.youtube.com/watch?v=K1JMjwJG2UM#t=17

On my implementation I have this:

try
        {
            var url = await YouTube.GetVideoUriAsync(vidPath, YouTubeQuality.Quality720P);
            VideoPlayer.Source = url.Uri;
            SourceSet = true;
            SupportedOrientations = SupportedPageOrientation.PortraitOrLandscape;
        }
        catch (Exception)
        {
            App.ViewModel.Busy = false;
            MessageBox.Show("This YouTube video can not be played within our app, please watch it using youtube.com");
        }
It sits there forever and never throws an exception.
Coordinator
Oct 10, 2013 at 6:05 AM
Are you using the library in WinRT or WP?
The nuget package has not changed, however the SVN code (working code) has massively changed toward a PCL solution...
Oct 10, 2013 at 4:48 PM
I am using the WP library.
Coordinator
Oct 22, 2013 at 7:59 PM
Please retry with v207
Nov 8, 2013 at 10:04 AM
Is this supposed to work with playing videos rated TV-MA? If so, is there anything I need to do code-wise to get this to work?
Coordinator
Nov 8, 2013 at 4:25 PM
What means tv-ma? No code options..
Coordinator
Nov 8, 2013 at 4:25 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Dec 1, 2013 at 10:55 PM
rsuter wrote:
What means tv-ma? No code options..
Sorry for the delay. TV-MA is a Youtube Partner-Rating that seems to block the video from being received using this toolkit. I added the following video to my playlist and I can't retrieve it:

http://www.youtube.com/watch?v=Du0nUG2YiSA&list=TL20Fut4h81x57ZGhW5GJBPPJgetcPRgjF
Coordinator
Dec 2, 2013 at 6:17 AM
It looks like the usual age restriction which should not be a problem.. But you need to get the MyToolkits source code and debug your scenario and see what http reselt is parsed...
Dec 2, 2013 at 11:56 AM
Ok, thanks. Will give that a try.