Video.RunTime プロパティ (Search)

ビデオ ファイルの長さを返します。

構文

public int RunTime { get; set; }

解説

RunTime プロパティには、Live Search エンジンから情報が得られる場合に、ビデオ ファイルの長さ (ミリ秒単位) を表す整数値が格納されます。

注意   Video API は、商業的利用のために確保されています。 このサービスの商業的利用の詳細については、api_tou@microsoft.com までお問い合わせください (英語のみ)。

この例では、Video SourceType からすべての (ALL) フィールドと Video フィールドを要求します。この例では、Title フィールドにあるビデオ ファイルの名前、ビデオのインデックスが作成されたページへの URLSourceTitle フィールドにあるビデオ ソースの名前、ビデオ ファイルの長さ、ファイル形式、幅と高さ、FileSize フィールドにあるビデオ ファイルのサイズ、および元のビデオの URI を示す再生 URL (PlayURL) を表示します。RunTime の値を表示するコードを、例の中で太字で強調表示しています。

try
{
MSNSearchService s = new MSNSearchService();
SearchRequest searchRequest = new SearchRequest();
int arraySize = 1;
SourceRequest[] sr = new SourceRequest[arraySize];

sr[0] = new SourceRequest();
sr[0].Source = SourceType.Video;
sr[0].ResultFields = ResultFieldMask.All | ResultFieldMask.Video;
sr[0].Count = 5;

searchRequest.Query = "trees";
searchRequest.Requests = sr;
// Developer Provisioning System で指定されたアプリケーション ID を 二重引用符で囲って 
// SearchRequest の AppID の値として入力します。
searchRequest.AppID = "YOUR_APP_ID_GOES_HERE";
searchRequest.CultureInfo = "en-US";
SearchResponse searchResponse;

searchResponse = s.Search(searchRequest);

foreach (SourceResponse sourceResponse in searchResponse.Responses)
    {
Result[] sourceResults = sourceResponse.Results;
if (sourceResponse.Total > 0)
        {
Console.WriteLine(sourceResponse.Source.ToString() + " - 結果総数:" + sourceResponse.Total.ToString());
Console.WriteLine();
        }
foreach (Result sourceResult in sourceResults)
        {
if ((sourceResult.Title != null) && (sourceResult.Title != String.Empty))
Console.WriteLine("タイトル:" + sourceResult.Title);
if ((sourceResult.Url != null) && (sourceResult.Url != String.Empty))
Console.WriteLine("URL:" + sourceResult.Url);
                
if (sourceResult.Video != null)
            {
Console.WriteLine("ソース タイトル:" + sourceResult.Video.SourceTitle.ToString());
Console.WriteLine("長さ:" + sourceResult.Video.RunTime.ToString());
Console.WriteLine("形式:" + sourceResult.Video.Format.ToString());
Console.WriteLine("幅:" + sourceResult.Video.Width.ToString());
Console.WriteLine("高さ:" + sourceResult.Video.Height.ToString());
Console.WriteLine("ファイル サイズ:" + sourceResult.Video.FileSize.ToString());
Console.WriteLine("再生 URL:" + sourceResult.Video.PlayUrl.ToString());
Console.WriteLine("*****************************************************");
            }

        }
    }
Console.WriteLine("終了するにはいずれかのキーを押してください。");
Console.ReadLine();
}
catch (SoapException fault)
{
Console.WriteLine(fault.Detail.InnerText.ToString());
}
catch (WebException webx)
{
Console.WriteLine(webx.ToString());
}

以下の出力の例は、このクエリの結果を示します。

Video - 結果総数: 37445

タイトル:Christmas trees damaged

URL:http://www.cnn.com/video/#/video/us/2007/11/16/kain.ct.christmas.trees.damaged.wfsb

ソース タイトル:CNN

長さ: 94928

形式:flv

幅: 576

高さ: 336

ファイル サイズ: 7295405

再生 URL:http://www.cnn.com/video/#/video/us/2007/11/16/kain.ct.christmas.trees.damaged.wfsb00

*****************************************************

タイトル:Kicking Trees

URL:http://www.youtube.com/watch?v=4VilgP2UtsI

ソース タイトル:YouTube

長さ: 62000

形式:flv

幅: 320

高さ: 240

ファイル サイズ: 2531137

再生 URL:http://www.youtube.com/watch?v=4VilgP2UtsI350425

*****************************************************

タイトル:Xmas Trees Ringing Up Profits

URL:https://video.msn.com/v/us/v.htm?g=b02d69e8-8caa-4ff4-a677-077aea6fdc8d

ソース タイトル:MSN Video

長さ: 79633

形式:wmv

幅: 320

高さ: 240

ファイル サイズ: 4952798

再生 URL:https://video.msn.com/v/us/v.htm?g=b02d69e8-8caa-4ff4-a677-077aea6fdc8d00

*****************************************************

終了するにはいずれかのキーを押してください。