从IIS7到iOS设备的流式点播视频

时间:2010-11-12 12:57:58

标签: objective-c iis-7 ios video-streaming

我从Scott Hanselman撰写了一篇关于如何使用IIS 7 Smooth Streaming和Transform Manager将视频流式传输到iPhone的文章。神奇的文章和一切都按照广告宣传100%。

http://www.hanselman.com/blog/CommentView.aspx?guid=86968CD5-FEEB-47F2-B02E-1EB4FA556379

我可以在iPad上使用浏览器并访问我的公司网站,在浏览器中观看视频播放,使用以下HTML嵌入到HTML页面中。

<html>
    <head>
        <title>iPhone page</title>
    </head>
    <body>
        <h1>Encoded stream</h1>
        <video width="640"
               height="480"
               src="http://name-of-video-here.ism/manifest(format=m3u8-aapl).m3u8"
               autoplay="true"
               controls="true" >Live</video>
     </body>
</html> 

我遇到的问题是当我尝试使用完全相同的URL“http://name-of-video-here.ism/manifest(format = m3u8-aapl).m3u8”并尝试使用“CustomMPMovie”或“MPMoviePlayerController”来自在同一台iPad上运行的自定义应用程序中,它不起作用。

播放视频的Objective-C

    NSURL *theURL = [NSURL URLWithString:[item url]];

    if ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 3.2) 
    {
        NSLog(@"> 3.2");
        CustomMPMovie *mp = [[CustomMPMovie alloc] initWithContentURL:theURL];

        if (mp)
        {
            mp.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
            [self.navigationController presentMoviePlayerViewControllerAnimated:mp];
            [mp shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight];
            [mp.moviePlayer play];
            [mp release];
        }
    }
    else if ([[[UIDevice currentDevice] systemVersion] doubleValue] < 3.2) 
    {
        NSLog(@"< 3.2");

        MPMoviePlayerController* theMovie = [[MPMoviePlayerController alloc] initWithContentURL: theURL];

        theMovie.scalingMode = MPMovieScalingModeAspectFill;

        // Register for the playback finished notification
        [[NSNotificationCenter defaultCenter]
         addObserver: self
         selector: @selector(myMovieFinishedCallback:)
         name: MPMoviePlayerPlaybackDidFinishNotification
         object: theMovie];

        // Movie playback is asynchronous, so this method returns immediately.
        [theMovie play];
    }

任何人都可以提供解释或可能的解决方案吗?

1 个答案:

答案 0 :(得分:1)

事实证明这是100%转储开发者错误。电影源类型需要切换到“MPMovieSourceTypeStreaming”,在我们这样做后,一切都开始工作了。 IIS Smooth Streaming和Transform Manager正在生产中,我们对输出非常满意。内置的Silverlight支持也非常棒。