数据库中的Silverlight视频操作 [英] Silverlight Video manipulation in Database

查看:90
本文介绍了数据库中的Silverlight视频操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Nilesh

从Youer到Silverlight Web应用程序中的帮助如何将视频存储在sql服务器数据库中以及如何显示.
请使用System.Windows;
发送此代码.

Hi I am Nilesh

Help From Youer side to in silverlight web application how stored video in sql server database and how to show .
Please Send this code .

推荐答案

使用System.Windows.Controls;
使用System.Windows.Media;
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用System.Windows.Documents;
使用System.Windows.Input;
使用System.Windows.Media.Animation;
使用System.Windows.Shapes;
使用System.Data.Services;
使用System.Configuration.Assemblies;
使用System.Resources;
使用System.ServiceModel.Configuration;
使用System.ServiceModel.Channels;
使用System.ServiceModel;
使用System.Net;
使用System.IO.IsolatedStorage;
使用System.IO;
使用System.Text;
命名空间SL4Demo
{

公共局部类MainPage:UserControl
{
//初始化捕获源的新实例
ProgressBar oBar;
情节提要oTimer;
TextBlock结果;
私有CaptureSource captureSource =新的CaptureSource();

公共MainPage()
{
InitializeComponent();
this.Loaded + = new RoutedEventHandler(MainPage_Loaded);
btnPlayCapture.Click + =新的RoutedEventHandler(btnPlayCapture_Click);
btnStopCapture.Click + =新的RoutedEventHandler(btnStopCapture_Click);
btnCaptureDevice.Click + =新的RoutedEventHandler(btnCaptureDevice_Click);

}

公共无效InitializeBehaviour()
{
oBar = this.FindName("myBar")as ProgressBar;
oTimer =新的Storyboard();
结果= this.FindName("myTextBloc")作为TextBlock;
oTimer.Duration = new Duration(new TimeSpan(600));
oTimer.Completed + =新的EventHandler(oTimer_Completed);
oTimer.Begin();
oBar.ValueChanged + =新RoutedPropertyChangedEventHandler< double& gt;(oBar_ValueChanged);
}

私有无效oBar_ValueChanged(对象发送者,RoutedPropertyChangedEventArgs< double& gt; e)
{
Result.Text =录制进度:" + e.NewValue.ToString()+%";
}
随机x =新的Random();

公共无效oTimer_Completed(对象发送者,EventArgs e)
{
int period = x.Next(1,5)* 100;
如果(oBar.Value& lt; oBar.Maximum)
{
System.Threading.Thread.CurrentThread.Join(period);
oBar.Value + = 1;
oTimer.Begin();
}
如果(oBar.Value& gt == oBar.Maximum)
{
captureSource.Stop();
Result.Text =录制完成";
}
其他
{
btnPlayCapture.IsEnabled = true;
}
}

void btnCaptureDevice_Click(object sender,RoutedEventArgs e)
{
TryCaptureDevice();

}

void btnStopCapture_Click(对象发送者,RoutedEventArgs e)
{
//停止捕获
captureSource.Stop();
btnPlayCapture.IsEnabled = true;
btnStopCapture.IsEnabled = false;

int period = x.Next(1,5)* 100;
如果(oBar.Value& lt; oBar.Maximum)
{
System.Threading.Thread.CurrentThread.Join(period);
oBar.Value + = 0;
oTimer.Pause();
}
如果(oBar.Value& gt == oBar.Maximum)
Result.Text =录制完成";
oBar.Value = 0;


}
void btnPlayCapture_Click(对象发送者,RoutedEventArgs e)
{
//如果设备已经在捕获,请停止它
如果(captureSource.State == CaptureState.Started)
{
captureSource.Stop();

}
//开始捕获
captureSource.Start();
btnPlayCapture.IsEnabled = false;
btnStopCapture.IsEnabled = true;
InitializeBehaviour();
}

void MainPage_Loaded(对象发送者,RoutedEventArgs e)
{
TryCaptureDevice();

}
私有void TryCaptureDevice()
{
//获取默认的视频捕获设备

VideoCaptureDevice videoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();
如果(videoCaptureDevice == null)
{
//未设置默认的视频捕获设备
btnPlayCapture.IsEnabled = false;
btnStopCapture.IsEnabled = false;
btnCaptureDevice.IsEnabled = true;
MessageBox.Show(您没有任何默认捕获设备");
}
其他
{
btnPlayCapture.IsEnabled = false;
btnStopCapture.IsEnabled = false;

//将捕获源设置为矩形的VideoBrush
VideoBrush videoBrush = new VideoBrush();
videoBrush.SetSource(captureSource);
rectWebCamView.Fill = videoBrush;
//检查Silverlight是否已经可以访问该设备或从用户授予访问权限
如果(CaptureDeviceConfiguration.AllowedDeviceAccess || CaptureDeviceConfiguration.RequestDeviceAccess())
{
btnPlayCapture.IsEnabled = true;
btnStopCapture.IsEnabled = false;
btnCaptureDevice.IsEnabled = false;

}
}
}
私有void btnCaptureDevice_Click_1(对象发送者,RoutedEventArgs e)
{

}
私有void btnPlayCapture_Click_1(对象发送者,RoutedEventArgs e)
{

}
私有void btnSave_Click(对象发送者,RoutedEventArgs e)
{

}
私有void btnStopCapture_Click_1(对象发送者,RoutedEventArgs e)
{
}
私有无效btnpreview_Click(对象发送者,RoutedEventArgs e)
{

}
}
}
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Data.Services;
using System.Configuration.Assemblies;
using System.Resources;
using System.ServiceModel.Configuration;
using System.ServiceModel.Channels ;
using System.ServiceModel;
using System.Net;
using System.IO.IsolatedStorage;
using System.IO;
using System.Text;
namespace SL4Demo
{

public partial class MainPage : UserControl
{
// initialize the new instance of the Capture Source
ProgressBar oBar;
Storyboard oTimer;
TextBlock Result;
private CaptureSource captureSource = new CaptureSource();

public MainPage()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(MainPage_Loaded);
btnPlayCapture.Click += new RoutedEventHandler(btnPlayCapture_Click);
btnStopCapture.Click += new RoutedEventHandler(btnStopCapture_Click);
btnCaptureDevice.Click += new RoutedEventHandler(btnCaptureDevice_Click);

}

public void InitializeBehaviour()
{
oBar = this.FindName("myBar") as ProgressBar;
oTimer = new Storyboard();
Result = this.FindName("myTextBloc") as TextBlock;
oTimer.Duration = new Duration(new TimeSpan(600));
oTimer.Completed += new EventHandler(oTimer_Completed);
oTimer.Begin();
oBar.ValueChanged += new RoutedPropertyChangedEventHandler&lt;double&gt;(oBar_ValueChanged);
}

private void oBar_ValueChanged(object sender, RoutedPropertyChangedEventArgs&lt;double&gt; e)
{
Result.Text = "Recording progress: " + e.NewValue.ToString() + " %";
}
Random x = new Random();

public void oTimer_Completed(object sender, EventArgs e)
{
int period = x.Next(1, 5) * 100;
if (oBar.Value &lt; oBar.Maximum)
{
System.Threading.Thread.CurrentThread.Join(period);
oBar.Value += 1;
oTimer.Begin();
}
if (oBar.Value &gt;= oBar.Maximum)
{
captureSource.Stop();
Result.Text = "Recording accomplished";
}
else
{
btnPlayCapture.IsEnabled = true;
}
}

void btnCaptureDevice_Click(object sender, RoutedEventArgs e)
{
TryCaptureDevice();

}

void btnStopCapture_Click(object sender, RoutedEventArgs e)
{
// Stop capturing
captureSource.Stop();
btnPlayCapture.IsEnabled = true;
btnStopCapture.IsEnabled = false;

int period = x.Next(1, 5) * 100;
if (oBar.Value &lt; oBar.Maximum)
{
System.Threading.Thread.CurrentThread.Join(period);
oBar.Value +=0;
oTimer.Pause ();
}
if (oBar.Value &gt;= oBar.Maximum)
Result.Text = "Recording accomplished";
oBar.Value=0;


}
void btnPlayCapture_Click(object sender, RoutedEventArgs e)
{
// If the device is already capturing Stop it
if (captureSource.State == CaptureState.Started )
{
captureSource.Stop();

}
// Start capturing
captureSource.Start();
btnPlayCapture.IsEnabled = false;
btnStopCapture.IsEnabled = true;
InitializeBehaviour();
}

void MainPage_Loaded(object sender, RoutedEventArgs e)
{
TryCaptureDevice();

}
private void TryCaptureDevice()
{
// Get the default video capture device

VideoCaptureDevice videoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();
if (videoCaptureDevice == null)
{
// Default video capture device is not setup
btnPlayCapture.IsEnabled = false;
btnStopCapture.IsEnabled = false;
btnCaptureDevice.IsEnabled = true;
MessageBox.Show("You don''t have any default capture device");
}
else
{
btnPlayCapture.IsEnabled = false;
btnStopCapture.IsEnabled = false;

// Set the Capture Source to the VideoBrush of the rectangle
VideoBrush videoBrush = new VideoBrush();
videoBrush.SetSource(captureSource);
rectWebCamView.Fill = videoBrush;
// Check if the Silverlight has already access to the device or grant access from the user
if (CaptureDeviceConfiguration.AllowedDeviceAccess || CaptureDeviceConfiguration.RequestDeviceAccess())
{
btnPlayCapture.IsEnabled = true;
btnStopCapture.IsEnabled = false;
btnCaptureDevice.IsEnabled = false;

}
}
}
private void btnCaptureDevice_Click_1(object sender, RoutedEventArgs e)
{

}
private void btnPlayCapture_Click_1(object sender, RoutedEventArgs e)
{

}
private void btnSave_Click(object sender, RoutedEventArgs e)
{

}
private void btnStopCapture_Click_1(object sender, RoutedEventArgs e)
{
}
private void btnpreview_Click(object sender, RoutedEventArgs e)
{

}
}
}


这篇关于数据库中的Silverlight视频操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆