[WM][VB][收看線上電視]

  • 7359
  • 0

[WM][VB][收看線上電視]

採用 Windows Mobile 界頂大名 OpenNETCF 的元件 Media Player Control 來播放影像檔

 

Step1:到 http://www.opennetcf.com/downloads/agreement.aspx?s=MediaPlayerControl_(WindowsMobile)_1.0_(Evaluation) 下載元件,按下 [Agree]

image

 

Step2:把下載完成的zip檔解壓縮裡面有一個MediaPlayerControl_(WindowsMobile)_1.0_(Evaluation)安裝檔執行起來,按下[Next]

clip_image002

 

Step3:請點選 I accept the terms in the License Agreement,在來按下 [Next>]

clip_image004

 

Step4:如果你不想要 Documentation或是 Samples可以點掉,可是Development Components一定要留住,在來還是按下[Next>]

clip_image006

 

Step5:如果你不想要安裝的預設路徑,自已可以按下[Browse..]另存路徑,在來按下[Install]

clip_image008

 

Step6:新增一個Visual Basic /智慧型專案 在表單上面增加四個功能表按鍵開檔、播放、暫停、停止

clip_image010

 

Step7:在方案總管視窗點選參考目錄,按下右鍵點選加入參考

clip_image012

 

Step8:選擇瀏覽dll 元件路徑為C:\Program Files\OpenNETCF\Media Player Controls (Windows Mobile) 1.0點選後按下[確定]

clip_image014

 

Step10:用開啟ie應用程式來收看線上電視畫面這個範例是大愛線上電視http://www.newdaai.tv/module/switch_stream.php?code=wmv_low

clip_image016

 

Step11:在 IE 畫面上按右鍵點選檢視原始檔,找出資源檔路徑mms:// 串流檔如下圖所示把他抄下來,等一下在pda應用程式中輸入進行收視。

 clip_image018clip_image020

Step12:在Form1表單裡面撰寫程式碼如下

 

Public Class Form1
    '新增一個 WindowsMediaPlayerControl
    Private wmp As New OpenNETCF.WindowsMobile.Media.WindowsMediaPlayerControl
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '把WindowsMediaPlayerControl佔滿整個表單
        wmp.Dock = DockStyle.Fill
        '將WindowsMediaPlayerControl ui 界面都拿掉剩下顯示影片畫面
        wmp.UiMode = OpenNETCF.WindowsMobile.Media.UiMode.None
        '最後這行一定要加要不然WindowsMediaPlayerControl就不會顯示影片
        Me.Controls.Add(wmp)
    End Sub

    Private Sub 開檔_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 開檔.Click
        Dim url As String = InputBox("輸入線上影片檔位置", "網址", "mms://stream-mms.daai.tv/wmtencoder/100k.wmv")
        wmp.MediaUrl = url
    End Sub

    Private Sub 播放_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 播放.Click
        wmp.Play()
    End Sub


    Private Sub 停止_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 停止.Click
        wmp.Stop()
    End Sub

    Private Sub 暫停_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 暫停.Click
        wmp.Pause()
    End Sub

End Class

 

Step13:在 VS2008 的功能表按下[偵錯]\[開始偵錯]

Step14:開始測式 mobile 部署應用,按下[開檔]輸入串流檔路徑

clip_image022

 

Step15:把檢視原始檔所抄下路徑輸入在文字方塊裡面,接下來按下[確定]

clip_image024

 

Step16:大功告成,可以收看了喔。

clip_image026

 

Step17: 源碼下載