'2009/07/20'에 해당되는 글 2건
- 2009/07/20 Silverlight - Media Player Sample (2)
- 2009/07/20 Javascript : Microsoft OS & Internet Explorer Agent Check
자료제공 : http://hugeflow.com/
예제소스 :
Silverlight 에서는 정말 쉽게 미디어 플레이어를 만들 수 있는 것 같다.
먼저 silverlight 프로젝트를 하나 만들고, Page.xaml을 blend로 열어준다.
blend에서 asset에 MediaControl 하나를 올려주고 버튼들을 올려 간단히 media 재생에 대한 내용을 작성해보자.
먼저 xaml
<UserControl x:Class="WebClientMediaTest.Page"
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="478" d:DesignHeight="337">
<Grid x:Name="LayoutRoot" Background="White">
<MediaElement Margin="0.39,0,-0.39,37" Source="http://hugeflow.com/Metro/Video/pigmap.wmv" x:Name="media"/>
<StackPanel Height="33" Margin="0.39,0,0,0" VerticalAlignment="Bottom" Orientation="Horizontal">
<Button Content="Play" Width="82.333" x:Name="btnPlay" Click="btnPlay_Click"/>
<Button Content="Pause" Width="82.333" x:Name="btnPause" Click="btnPause_Click"/>
<Button Content="Stop" Width="82.333" x:Name="btnStop" Click="btnStop_Click"/>
<Slider Width="216" x:Name="slideVolume" ValueChanged="slideVolume_ValueChanged"/>
</StackPanel>
</Grid>
</UserControl>
다음은 C# 코드
다른 코드들 보다 어쩌먼 정말 간단한 코드같다 -_ -;;using System.Windows;
using System.Windows.Controls;namespace WebClientMediaTest
{
public partial class Page : UserControl
{
public Page()
{
InitializeComponent();Loaded += new RoutedEventHandler(Page_Loaded);
}void Page_Loaded(object sender, RoutedEventArgs e)
{
slideVolume.Value = slideVolume.Maximum * media.Volume;
}private void btnPlay_Click(object sender, RoutedEventArgs e)
{
media.Play();
}private void btnPause_Click(object sender, RoutedEventArgs e)
{
media.Pause();
}private void btnStop_Click(object sender, RoutedEventArgs e)
{
media.Stop();
}private void slideVolume_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
media.Volume = slideVolume.Value / slideVolume.Maximum;
}
}
}
별다른 기법도 없고, 단지 컨트롤 에서 제공하는 간단한 산수만 한다면 사용할 수 있는..
'.NET > Silverlight' 카테고리의 다른 글
| Silverlight - Animation (0) | 2009/07/21 |
|---|---|
| Silverlight - Media Player Sample (2) | 2009/07/20 |
| Silverlight + Expression = Visual Kitchen (0) | 2009/07/16 |
| Silverlight - Network Sample 2 (0) | 2009/07/15 |
| Silverlight - Network Example 1 (0) | 2009/07/13 |
| Silverlight – Custom control (0) | 2009/07/03 |
Javascript : Microsoft OS & Internet Explorer Agent Check

Web Page에서 브라우저와 OS에 따라 다른 조치를 해야 하는 경우가 있습니다.
그래서 브라우저에서 받아올 수 있는 User Agent 값을 분석해서 이에 이용하게 되죠.
다음과 같이 값을 체크하는 부분을 공통으로 작성하여 가져다가 쓰면 좋을 것 같네요.
테스트 페이지(Test page): BrowserTest.html
<html>
<head>
<title>Browser Agent Test</title>
<script type="text/javascript">
function BrowserIs()
{
var agt = navigator.userAgent.toLowerCase();
this.osver = 1.0;
if (agt)
{
var stOSVer = agt.substring(agt.indexOf("windows ") + 11);
this.osver = parseFloat(stOSVer);
}
this.major = parseInt(navigator.appVersion);
this.nav = ((agt.indexOf('mozilla')!=-1)&&((agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible')==-1)));
this.nav2 = (this.nav && (this.major == 2));
this.nav3 = (this.nav && (this.major == 3));
this.nav4 = (this.nav && (this.major == 4));
this.nav6 = this.nav && (this.major == 5);
this.nav6up = this.nav && (this.major >= 5);
this.nav7up = false;
if (this.nav6up)
{
var navIdx = agt.indexOf("netscape/");
if (navIdx >=0 )
this.nav7up = parseInt(agt.substring(navIdx+9)) >= 7;
}
this.ie = (agt.indexOf("msie")!=-1);
this.aol = this.ie && agt.indexOf(" aol ")!=-1;
if (this.ie)
{
var stIEVer = agt.substring(agt.indexOf("msie ") + 5);
this.iever = parseInt(stIEVer);
this.verIEFull = parseFloat(stIEVer);
}
else
this.iever = 0;
this.ie3 = ( this.ie && (this.major == 2));
this.ie4 = ( this.ie && (this.major == 4));
this.ie4up = this.ie && (this.major >=4);
this.ie5up = this.ie && (this.iever >= 5);
this.ie55up = this.ie && (this.verIEFull >= 5.5);
this.ie6up = this.ie && (this.iever >= 6);
this.ie7up = this.ie && (this.iever >= 7);
this.ie8up = this.ie && (this.iever >= 8);
this.win16 = ((agt.indexOf("win16")!=-1)
|| (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1)
|| (agt.indexOf("windows 16-bit")!=-1) );
this.win31 = (agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) ||
(agt.indexOf("windows 16-bit")!=-1);
this.win98 = ((agt.indexOf("win98")!=-1)||(agt.indexOf("windows 98")!=-1));
this.win95 = ((agt.indexOf("win95")!=-1)||(agt.indexOf("windows 95")!=-1));
this.winnt = ((agt.indexOf("winnt")!=-1)||(agt.indexOf("windows nt")!=-1));
this.win32 = this.win95 || this.winnt || this.win98 ||
((this.major >= 4) && (navigator.platform == "Win32")) ||
(agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1);
this.os2 = (agt.indexOf("os/2")!=-1)
|| (navigator.appVersion.indexOf("OS/2")!=-1)
|| (agt.indexOf("ibm-webexplorer")!=-1);
this.mac = (agt.indexOf("mac")!=-1);
this.mac68k = this.mac && ((agt.indexOf("68k")!=-1) ||
(agt.indexOf("68000")!=-1));
this.macppc = this.mac && ((agt.indexOf("ppc")!=-1) ||
(agt.indexOf("powerpc")!=-1));
this.w3c = this.nav6up;
}
function ObjectStripShow(obj, outputDivId)
{
var outputStr = "";
for (var i in obj) outputStr += i + " = " + eval('obj.' + i) + "<br/>\n";
if (outputDivId == null || document.getElementById(outputDivId) == null)
document.write(outputStr);
else
document.getElementById(outputDivId).innerHTML = outputStr;
}
window.onload = function()
{
var bi = new BrowserIs();
ObjectStripShow(bi, 'output');
};
</script></head>
<body>
<div id="output">
</div>
</body>
</html>
결과(Result ):
osver = 5.2
major = 4
nav = false
nav2 = false
nav3 = false
nav4 = false
nav6 = false
nav6up = false
nav7up = false
ie = true
aol = false
iever = 7
verIEFull = 7
ie3 = false
ie4 = true
ie4up = true
ie5up = true
ie55up = true
ie6up = true
ie7up = true
ie8up = false
win16 = false
win31 = false
win98 = false
win95 = false
winnt = true
win32 = true
os2 = false
mac = false
mac68k = false
macppc = false
w3c = false
'Web > JavaScript' 카테고리의 다른 글
| Javascript - Element Opacity Control for Cross Browser (0) | 2010/02/18 |
|---|---|
| Ext JS 3.0 (0) | 2009/09/23 |
| Javascript : Microsoft OS & Internet Explorer Agent Check (0) | 2009/07/20 |
| Javascript – 이벤트 추가 (0) | 2009/05/08 |
| 스크립트에서 클라이언트 프로그램 실행 시키는 방법 (3) | 2009/02/17 |
| [js]브라우저의 오른쪽 상단의 X표시를 누르거나 창을 닫을때 이벤트 잡기! (1) | 2009/01/05 |
3-3.WebClientMediaTest.zip



Prev




