【问题标题】:WP8 MediaElement SourceWP8 媒体元素源
【发布时间】:2013-08-13 07:35:11
【问题描述】:

我正在尝试设置一个媒体元素来播放来自 http 源的视频。来源来自网络摄像机,但它无法正常工作,我不知道为什么。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using FullCam.Resources;

namespace FullCam
{
    public partial class MainPage : PhoneApplicationPage
{

    // Constructor
    public MainPage()
    {
        string sourceURL = "http://xxx.xxx.xxx.xxx/display_pic.cgi?cam=1&id=807933130&res=hi&format=mp4&txmode=binary";
        InitializeComponent();

       // Sample code to localize the ApplicationBar
        BuildLocalizedApplicationBar();
        iniCamBox(camBox_1, sourceURL, "user", "password");
    }

    private void BuildLocalizedApplicationBar()
     {
        // Set the page's ApplicationBar to a new instance of ApplicationBar.
        ApplicationBar = new ApplicationBar();

        // Create a new button and set the text value to the localized string from AppResources.
        ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
        appBarButton.Text = AppResources.AppBarButtonText;
       ApplicationBar.Buttons.Add(appBarButton);

       // Create a new menu item with the localized string from AppResources.
       ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
        ApplicationBar.MenuItems.Add(appBarMenuItem);
    }

    private void iniCamBox(MediaElement box, string source, string user, string pass)
    {
        Uri mainSource = new Uri(source);

        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(mainSource);
        req.Credentials = new NetworkCredential(user, pass);

        box.Source = mainSource;
        box.Play();
    }
}
}

我以前从未这样做过,所以我不确定我是否正确进行。

【问题讨论】:

  • 嗨!您是否尝试与其他玩家一起阅读您的“sourceUrl”? (VLC、Windows 媒体播放器或浏览器)并且有效??
  • 我在 chrome 浏览器中使用了 sourceurl,它作为 jpeg 和 mp4 源都可以正常工作。
  • box.Play() 放入_MediaOpened

标签: windows-phone-8 mp4 mediaelement ip-camera


【解决方案1】:

我的建议是看看这个教程MSDN Media Element

【讨论】:

  • 我看了一下教程,但我仍然不明白为什么我上面的内容不起作用?
  • vidBox 未定义/或至少未在您显示的代码中/
  • 我使用可视化编辑器放置了控件。它在那里,只是似乎没有从源头播放视频?源工作正常。
  • stackoverflow.com/questions/7117589/… 听起来与您的问题相似。
猜你喜欢
  • 1970-01-01
  • 2011-08-06
  • 1970-01-01
  • 2011-01-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多