MarkerResource - Captions

Aug 11, 2010 at 6:57 PM
While looking at the sample, came across the sample of external captions file. Code below: (body tag trimmed down for my sample) Step: 1 ===== <?xml version="1.0" encoding="utf-8" ?> <tt xml:lang="en-GB" xmlns="http://www.w3.org/2006/10/ttaf1"> <head> <metadata> <ttm:title xmlns:ttm="http://www.w3.org/2006/10/ttaf1#metadata" /> <ttm:desc xmlns:ttm="http://www.w3.org/2006/10/ttaf1#metadata" /> <ttm:copyright xmlns:ttm="http://www.w3.org/2006/10/ttaf1#metadata" /> </metadata> <styling> <style xml:id="backgroundStyle" p5:fontFamily="proportionalSansSerif" p5:fontSize="16px" p5:textAlign="center" p5:origin="10% 85%" p5:extent="80% 10%" p5:backgroundColor="rgba(0,0,0,100)" p5:displayAlign="center" xmlns:p5="http://www.w3.org/2006/10/ttaf1#styling" /> <p5:style xml:id="speakerStyle" p5:style="backgroundStyle" p6:color="white" p6:backgroundColor="transparent" xmlns:p6="http://www.w3.org/2006/10/ttaf1#styling" xmlns:p5="http://www.w3.org/2006/10/ttaf1" /> </styling> <layout> <p5:region xml:id="speaker" p5:style="speakerStyle" p6:zIndex="1" xmlns:p6="http://www.w3.org/2006/10/ttaf1#styling" xmlns:p5="http://www.w3.org/2006/10/ttaf1" /> <p5:region xml:id="background" p5:style="backgroundStyle" p6:zIndex="0" xmlns:p6="http://www.w3.org/2006/10/ttaf1#styling" xmlns:p5="http://www.w3.org/2006/10/ttaf1" /> </layout> </head> <body>
<p4:p p4:region="speaker" p4:begin="00:00:05:00" p4:end="00:00:10:00" xmlns:p4="http://www.w3.org/2006/10/ttaf1">Test caption? </p4:p> <p4:p p4:region="speaker" p4:begin="00:00:28:00" p4:end="00:00:29:00" xmlns:p4="http://www.w3.org/2006/10/ttaf1">How do you like this test caption? </p4:p>
</body> </tt> ----- Step: 2 ===== Added following code to my page public MainPage() { InitializeComponent(); this.SPlayer.Playlist.Clear(); this.SPlayer.AutoPlay = true; this.SPlayer.BufferingTime = new TimeSpan(0, 0, 5); this.SPlayer.Playlist.Add(new PlaylistItem() { MediaSource = new Uri("http://localhost/test/smooth1/Culture01.ism/Manifest"), DeliveryMethod = DeliveryMethods.AdaptiveStreaming, MarkerResource = new MarkerResource() { Format = "TTAF1-DFXP", Source = new Uri("http://localhost/test/samplecaptions.xml") }, PreRollAdvertisement = new Advertisement() { AdSource = new Uri("http://localhost/test/ads/Vasudev.ism/Manifest"), Duration = new TimeSpan(0, 0, 26), DeliveryMethod = DeliveryMethods.AdaptiveStreaming, StartTime = new TimeSpan(0,0,5) } }); //this.SPlayer.GoToPlaylistItem(0); //SPlayer.TimelineMarkerReached += new EventHandler<Microsoft.SilverlightMediaFramework.Core.TimelineMarkerReachedInfo>(SPlayer_TimelineMarkerReached); //SPlayer.MediaOpened += new EventHandler(SPlayer_MediaOpened); //SPlayer.MediaEnded += new EventHandler(SPlayer_MediaEnded); } ** Smooth streaming assets and samplecaptions.xml are under the default root and running the project that reference to these files in VS 2010. Captions are not displayed, am i doing something wrong? Thanks,
Aug 11, 2010 at 6:59 PM
Edited Aug 11, 2010 at 8:38 PM

Sorry don't know why it displayed this way, here is the question:

** Smooth streaming assets and samplecaptions.xml are under the default root and running the project that reference to these files in VS 2010.

Captions are not displayed, am i doing something wrong?

InitializeComponent();

this.SPlayer.Playlist.Clear();

this.SPlayer.AutoPlay = true;

this.SPlayer.BufferingTime = new TimeSpan(0, 0, 5);

this.SPlayer.Playlist.Add(new PlaylistItem()

{ MediaSource = new Uri("http://localhost/test/smooth1/Culture01.ism/Manifest"), DeliveryMethod = DeliveryMethods.AdaptiveStreaming,

MarkerResource = new MarkerResource()

{ Format = "TTAF1-DFXP", Source = new Uri("http://localhost/test/samplecaptions.xml") },

PreRollAdvertisement = new Advertisement() {

AdSource = new Uri("http://localhost/test/ads/Vasudev.ism/Manifest"), Duration = new TimeSpan(0, 0, 26), DeliveryMethod = DeliveryMethods.AdaptiveStreaming, StartTime = new TimeSpan(0,0,5) } });

Thanks,

Aug 12, 2010 at 9:34 AM

I've also been recently wandering about markers and chapters, I was wandering what support for adding markers and chapters there currently is in the SMFPlayer. I was hopeing to supply a smooth streaming client manifest which has some chapters defined in the way described here - http://msdn.microsoft.com/en-us/library/ee958034(VS.90).aspx. But I don't think that populating the chapters from a client manifest is currently supported.

Aug 12, 2010 at 5:08 PM

The markers worked while following the MSDN, but with mediaElement not the SMF based player. I tetsed that one and was hoping to replicate with SMF player and saw three options under the sample source code for textual markers, external captions etc..and was trying if i could do that since it is useful in my project for displaying time sensitive advertisement using captions.

** Over and above this, if i were to add the captions to the Preroll clip, didn't find a way if someone tried that one. e.g. Displaying spanish language captions for an ad in engllish and english for spanish ads.

Thanks for the comment.

 

Coordinator
Aug 13, 2010 at 2:56 AM

Hey bhaktavatsal, sorry you're having a tough time.  Do you have an example app you can post?  If so I'll take a looks and see if I can figure out what the problem is.

Aug 13, 2010 at 3:23 AM

Yes, its just two simple pages. Where can i send you?

I have tried to debug and i think there is some exception being thrown in TimedText plugin, but not sure. That exception is not reflected but showing being logged somewhere, not sure either where it is logging, as somehow i can't debug the entire the code. It only let me loop through some of the code and not all.

Thanks,

 

Aug 13, 2010 at 6:42 PM
Edited Aug 13, 2010 at 6:49 PM

MainPage.xaml

            this.SPlayer.Playlist.Clear();
            this.SPlayer.AutoPlay = true;

            this.SPlayer.BufferingTime = new TimeSpan(0, 0, 5);
            this.SPlayer.Playlist.Add(new PlaylistItem()
            {
                MediaSource = new Uri("http://localhost/test/smooth1/Culture01.ism/Manifest"),
                DeliveryMethod = DeliveryMethods.AdaptiveStreaming,
                MarkerResource = new MarkerResource()
                {
                    Format = "TTAF1-DFXP",
                    Source = new Uri(http://localhost/test/samplecaptions.xml)
                },
                PreRollAdvertisement = new Advertisement()
                {
                    AdSource = new Uri("http://localhost/test/ads/Vasudev.ism/Manifest"),
                    Duration = new TimeSpan(0, 0, 26),
                    DeliveryMethod = DeliveryMethods.AdaptiveStreaming,
                    StartTime = new TimeSpan(0,0,5)                                         // Looking for MarkerResource here as well for captions within the ads
                }
            });
-----

Sample captions file below.

  <?xml version="1.0" encoding="utf-8" ?> 
- <tt xml:lang="en-GB" xmlns="http://www.w3.org/2006/10/ttaf1">
- <head>
- <metadata>
  <ttm:title xmlns:ttm="http://www.w3.org/2006/10/ttaf1#metadata" /> 
  <ttm:desc xmlns:ttm="http://www.w3.org/2006/10/ttaf1#metadata" /> 
  <ttm:copyright xmlns:ttm="http://www.w3.org/2006/10/ttaf1#metadata" /> 
  </metadata>
- <styling>
  <style xml:id="backgroundStyle" p5:fontFamily="proportionalSansSerif" p5:fontSize="16px" p5:textAlign="center" p5:origin="10% 85%" p5:extent="80% 10%" p5:backgroundColor="rgba(0,0,0,100)" p5:displayAlign="center" xmlns:p5="http://www.w3.org/2006/10/ttaf1#styling" /> 
  <p5:style xml:id="speakerStyle" p5:style="backgroundStyle" p6:color="white" p6:backgroundColor="transparent" xmlns:p6="http://www.w3.org/2006/10/ttaf1#styling" xmlns:p5="http://www.w3.org/2006/10/ttaf1" /> 
  </styling>
- <layout>
  <p5:region xml:id="speaker" p5:style="speakerStyle" p6:zIndex="1" xmlns:p6="http://www.w3.org/2006/10/ttaf1#styling" xmlns:p5="http://www.w3.org/2006/10/ttaf1" /> 
  <p5:region xml:id="background" p5:style="backgroundStyle" p6:zIndex="0" xmlns:p6="http://www.w3.org/2006/10/ttaf1#styling" xmlns:p5="http://www.w3.org/2006/10/ttaf1" /> 
  </layout>
  </head>
- <body>
- <div>
  <p4:p p4:region="speaker" p4:begin="00:00:05:00" p4:end="00:00:10:50" xmlns:p4="http://www.w3.org/2006/10/ttaf1">Test caption?</p4:p> 
  <p4:p p4:region="speaker" p4:begin="00:00:12:00" p4:end="00:00:15:00" xmlns:p4="http://www.w3.org/2006/10/ttaf1">How do you like this test caption?</p4:p> 
  </div>
  </body>
  </tt>
I have added references for the following assemblies.
Microsoft.SilverlightMediaFramework.Core
Microsoft.SilverlightMediaFramework.Plugins
Microsoft.SilverlightMediaFramework.Plugins.SmoothStreaming
Microsoft.SilverlightMediaFramework.Plugins.TimedText
Microsoft.SilverlightMediaFramework.Utilities
Microsoft.Web.Media.SmoothStreaming
Environment running under Windows 7 Professional, 64 bit, VS 2010.
In the first attempt, only replicating what you have as samplecaptions under the samples project with the source code download.
Thanks,

Aug 13, 2010 at 7:51 PM

Tried with one more option, exactly like samples page - CaptionMarkers.xaml (under Samples/Samples/Markers).

<UserControl x:Class="SMFv2Test.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:Core="http://schemas.microsoft.com/smf/2010/xaml/player" 
	xmlns:Media="http://schemas.microsoft.com/smf/2010/xaml/media"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot" Background="White">
        <Core:SMFPlayer x:Name="SPlayer" CaptionsVisibility="Visible">
            <Core:SMFPlayer.Playlist>
                <Media:PlaylistItem DeliveryMethod="AdaptiveStreaming" MediaSource="http://localhost/test/smooth1/Culture01.ism/Manifest">
                    <Media:PlaylistItem.MarkerResource>
                        <Media:MarkerResource Format="TTAF1-DFXP" Source="samplecaptions.xml"></Media:MarkerResource>
                    </Media:PlaylistItem.MarkerResource>
                </Media:PlaylistItem>
            </Core:SMFPlayer.Playlist>
        </Core:SMFPlayer>

    </Grid>
</UserControl>

Also dropping the samplecaptions.xml under the same project, instead of another project. Changing the reference above as per sample instead of assembly. Still not showing up, it must be i am doing something wrong, but can't figure it out.

Coordinator
Aug 16, 2010 at 7:11 PM

bhaktavatsal, do you have an FTP or HTTP site where you can drop a complete solution?

Aug 16, 2010 at 7:32 PM

File name is SMFv2Test.zip and domain is bhaktilive com - add the dot between bhaktilive and com.

I have added this project in to the source solution that i have downloaded for SMF and added references to this project.

Thanks for looking in to it.

 

Coordinator
Aug 16, 2010 at 9:45 PM

Took a look at your project and there was an error in your caption file.  Where you had 00:00:10:50 the correct formatting of this timecode is 00:00:10.500 which equals 10 seconds and 500 milliseconds.  The format you were using indicated 10 seconds and 50 frames.  I posted a functional project using this code here: http://smf.vertigo.com/files/bhakti.zip

Aug 17, 2010 at 3:22 AM

Yes, it works with the code and lib files you sent. Couple of differences i have seen as follows.

1) If i point the references to the one you sent then the sample works but not with the /bin download i had earlier. Changing the references in the project you sent replicates that behaviour.

2) Changing the caption file back to 00:00:10:50 works if i download the v2.1 dll's and adds that as a reference.

I have few more questions on the caption behaviours, but will post it later as the current issue is solved.

Thank you very much for the help.

Aug 17, 2010 at 5:52 AM

Sorry, one more scenario left out.

Did you tried with the code behind that i had in the sample? It still does not work, pasted the code behind in to your sample and it does not work.

Thanks,

 

Aug 17, 2010 at 6:45 PM
Hi Kevin, I can't seem to get captions to work either when using code to add aDFXP marker resource. - If I put the MarkerResource in the XAML, it works fine. - If I try to add the same MarkerResource in code, no captions show up. I have tried adding this like bhaktavatsal's sample where the MarkerResource is in the new PlaylistItem() , and also like this: MarkerResource testMarkerResource = new MarkerResource(); testMarkerResource.Format = "TTAF1-DFXP"; testMarkerResource.Source = new Uri("samplecaptions.xml", UriKind.Relative); SMFPlayerTest.CurrentPlaylistItem.MarkerResource = testMarkerResource; - The log shows no errors, and that the timedtext file was 100% loaded, but captions won't display. Thanks, -Dan
Aug 17, 2010 at 6:48 PM

Ack! I had the same post issue that bhaktavatsal had... ? Here is my post again:

Hi Kevin, I can't seem to get captions to work either when using code to add aDFXP marker resource.
 
- If I put the MarkerResource in the XAML, it works fine.
 
- If I try to add the same MarkerResource in code, no captions show up. I have tried adding this like bhaktavatsal's sample where the MarkerResource is in the new PlaylistItem() , and also like this:
 
MarkerResource testMarkerResource = new MarkerResource();
testMarkerResource.Format = "TTAF1-DFXP";
testMarkerResource.Source = new Uri("samplecaptions.xml", UriKind.Relative);
SMFPlayerTest.CurrentPlaylistItem.MarkerResource = testMarkerResource;

 
- The log shows no errors, and that the timedtext file was 100% loaded, but captions won't display.
 
Thanks for any pointers,
-Dan
Coordinator
Aug 18, 2010 at 6:54 PM

Dan, you have to specify the PlaylistItem.MarkerResource property before the PlaylistItem is loaded.  Once it is loaded and is the "CurrentPlaylistItem" it is too late, the player won't see changes to the property and load the MarkerResource.  I recommend setting this property before adding the PlaylistItem to the Playlist.

Aug 18, 2010 at 11:20 PM

Following your instructions, that works now, but now I have a different issue.

If a MarkerResource is specified in the XAML for one PlaylistItem, then I try to add another PlaylistItem in the code, it won't work. If I remove the MarkerResource from the XAML for the first item, it does work.

Also, once I do have captions working, if I skip from one PlaylistItem to the next, then back, the captions stop working.

Any ideas?

Aug 20, 2010 at 3:22 PM

Is it then wrong to put the code above i have for adding markerresource? or that is supposed to work too?

Nov 21, 2010 at 4:09 PM

Hi all,

Using krohling's exmaple. (http://smf.vertigo.com/files/bhakti.zip)

The video can be played but the caption is not shown.

I tried to open new a project using XAML or .cs to create MarkerResource but none of them works.

 

Any reason will cause this problem..? I am really frustrated....

 

Thanks,

 

Nov 21, 2010 at 4:31 PM

Also, what is the different between SMFPlayer.Caption and SMFPlayer.CurrentPlaylistItem.MarkerResource?

any setting on SMFPlayer.Caption is needed?

 

Thanks again,

Jan 4, 2012 at 10:15 PM
Edited Jan 4, 2012 at 10:59 PM

same as qwerasd, the video is playing but no captions neither xml or dfxp file.