Nextrek
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace SLP
{
public partial class MainPage : UserControl
{
public MainPage()
{
Loaded += MainPage_Loaded;
InitializeComponent();
}
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
System.Windows.Browser.HtmlPage.RegisterScriptableObject("Player", this);
SmoothPlayer.MediaOpened += SmoothPlayer_MediaOpened;
}
void SmoothPlayer_MediaOpened(object sender, RoutedEventArgs e)
{
SmoothPlayer.Play();
}
[System.Windows.Browser.ScriptableMember]
public void setStreamUrl(string url)
{
SmoothPlayer.AutoPlay = true;
SmoothPlayer.SmoothStreamingSource = new Uri(url);
//SmoothPlayer.SmoothStreamingSource =
}
[System.Windows.Browser.ScriptableMember]
public void Play()
{
Deployment.Current.Dispatcher.BeginInvoke(delegate
{
SmoothPlayer.Play();
});
}
[System.Windows.Browser.ScriptableMember]
public void Stop()
{
Deployment.Current.Dispatcher.BeginInvoke(delegate
{
try
{
SmoothPlayer.Stop();
}
catch
{
}
});
}
[System.Windows.Browser.ScriptableMember]
public void Pause()
{
Deployment.Current.Dispatcher.BeginInvoke(delegate
{
SmoothPlayer.Pause();
});
}
[System.Windows.Browser.ScriptableMember]
public void Reload()
{
Deployment.Current.Dispatcher.BeginInvoke(delegate
{
SmoothPlayer.Stop();
SmoothPlayer.Play();
});
}
private void PlayButton_Loaded(object sender, RoutedEventArgs e)
{
//We need to prepopulate the value of Play/Pause button content, we need to check AutoPlay
switch (SmoothPlayer.AutoPlay)
{
case false:
PlayButton.Content = "Play";
break;
case true:
PlayButton.Content = "Pause";
break;
}
}
private void PlayButton_Click(object sender, RoutedEventArgs e)
{
//Monitor the state of the content to determine the right action to take on this button being clicked
//and then change the text to reflect the next action
switch (SmoothPlayer.CurrentState)
{
case Microsoft.Web.Media.SmoothStreaming.SmoothStreamingMediaElementState.Playing:
SmoothPlayer.Pause();
PlayButton.Content = "Play";
break;
case Microsoft.Web.Media.SmoothStreaming.SmoothStreamingMediaElementState.Stopped:
case Microsoft.Web.Media.SmoothStreaming.SmoothStreamingMediaElementState.Paused:
SmoothPlayer.Play();
PlayButton.Content = "Pause";
break;
}
}
private void StopButton_Click(object sender, RoutedEventArgs e)
{
//This should simply stop the playback
SmoothPlayer.Stop();
//We should also reflect the chang on the play button
PlayButton.Content = "Play";
}
}
}
|
Revision |
Author |
Commited |
Message |
9
|
DRuega
|
Mon 06 May, 2013 21:54:02 +0000 |
|