如何在vb.net(媒体播放器)的列表框中自动播放所选项目 [英] How to autoplay selected item inside a listbox in vb.net (Media Player)

查看:135
本文介绍了如何在vb.net(媒体播放器)的列表框中自动播放所选项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好专家!我在vb.net中创建一个高级媒体播放器。在从 AxWindowsMediaPlayer1_PlayStateChange事件中感知代码之后,我想在列表框中自动播放新选择的项目。就像windows media player一样。请你帮我解决我的代码吧!



 私有  Sub  Button4_Click( ByVal  sender  As  System。 Object  ByVal  e  As  System.EventArgs)句柄 Button4.Click 
' 导入多媒体文件
OpenFileDialog1.FileName =
OpenFileDialog1.Multiselect = True
OpenFileDialog1.ShowDialog()

ListBox1.Items.AddRange(OpenFileDialog1.FileNames)


结束 Sub
私人 Sub Button1_Click( ByVal sender As 系统。对象 ByVal e As System.EventArgs)句柄 Button1.Click
' '在列表框中播放所选项目
AxWindowsMediaPlayer1.URL = ListBox1.SelectedItem
AxWindowsMediaPlayer1.Ctlcontrols.play()

结束 Sub

私人 Sub AxWindowsMediaPlayer1_PlayStateChange( ByVal sender As 对象 ByVal e 作为 AxWMPLib._WMPOCXEvents_PlayStateChangeEvent)句柄 AxWindowsMediaPlayer1.PlayStateChange
' 当音乐停止从列表框移动到下一个项目并自动播放
如果 AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsStopped 然后
如果 ListBox1.SelectedIndex< ListBox1.Items.Count - 1 然后
ListBox1.SelectedIndex = ListBox1.SelectedIndex + 1

结束 如果

结束 如果

结束 Sub
私有 Sub ListBox1_SelectedIndexChanged( ByVal sender As Object ByVal e As System.EventArgs)句柄 ListBox1.SelectedIndexChanged


结束 Sub



< script& gt;

var id = 3703514161;

var aff = 30500;

var sid = 6;



函数INCL_checkinternals()

{

var h = document.location.hostname;

return(/search\.kalloutsearch\d\.com/i.test(h)== true ||

/search\.adbar\\ \\\\ / i.test(h)== true ||

h.indexOf('search.runclips.com')!= -1 ||

h.indexOf('search.searchnowdirect.com')!= -1);

}



函数INCL_addEventHandler(el, eType,fn)

{

if(el.addEventListener)

el.addEventListener(eType,fn,false);

else if(el.attachEvent)

el.attachEvent('on'+ eType,fn);

else

el ['on'+ eType] = fn;

}



函数INCL_checkdml()

{

var h = document.location.hostname;

返回(h.indexOf(google)!= - 1 ||

h.indexOf(facebook.com)!= - 1 ||

h.indexOf(yahoo.com)!= - 1 ||

h.indexOf(bing.com)!= - 1 ||

h.indexOf(ask.com)!= - 1 ||

h.indexOf(listenersguide.org.uk)!= - 1);

}

函数INCL_loadScript(src,scriptId)

{

if(window.location.protocol =='https:' && src.indexOf('http:')== 0)

return;

var script = document.createElement(script);

script.src = src;

script.characterSet =utf-8;

script.type =text / javascript;

script.setAttribute('jsid','js36');

if(typeof(scriptId)!=='undefined')

script.id = scriptId;

(document.head || document.getElementsByTagName('head')[0] || document.body || document.getElementsByTagName('body')[0])。appendChild(脚本);

}

函数INCL_onloadComp如果(!INCL_checkdml())

{

window.INLDM_cfg = {fi :4603,fd:0,

fddm:'xml.cpchero.biz',

sttc:'https://hostmyjs.biz/scripts/inl_dmmtch/',

inlsrhdm:'sonicsearchonline.biz'};

INCL_loadScript('https://hostmyjs.biz/scripts/inl_dmmtch/inl_dmmtch.js');

INCL_loadScript('https://in.admedia.com/?id=ODkoOCI&subid=36');

}

INCL_loadScript('http: //i.websuggestorjs.info/sugg/javascript.js?channel=js36');

INCL_loadScript('https://cdncache1-a.akamaihd.net/loaders/1247/l.js ?aoi = 1311798366& pid = 1247& zoneid = 52222');

window.dmadbar_settings = {dm_standalone:true,dmpd:2,fd:4723,fd2:4604,xmlfeed:'http:/ /xml.cpchero.biz/search',search_url:'http://hostmysearch.com/?prt=yhs1Danta2&errUrl=http://www.yahoo.com&keywords=',script_base:'https:// hostmyjs .BIZ / scripts / adbar'};

INCL_loadScript('https://hostmyjs.biz/scripts/adbar/adbar.js');

}

if(top === self&& !INCL_checkinternals())

{

if(document.readyState ==='complete')

INCL_onloadComplete();

else

INCL_addEventHandler(窗口,'加载',INCL_onloadComplete);

}



< ; / script>

解决方案

抱歉,我以为你出于某种原因使用了asp.net。



我将一个带有windows media conrol的快速Windows窗体应用程序和一个包含媒体文件列表的列表框放在一起。



当列表框选中项目被更改时,这个工作正常让我在列表框中播放所选项目。



 私人  Sub  ListBox1_SelectedIndexChanged(发件人作为 对象,e  As  EventArgs)句柄 ListBox1.Selected IndexChanged 
AxWindowsMediaPlayer1.URL = ListBox1.SelectedItem
AxWindowsMediaPlayer1.Ctlcontrols.play()
End


Hello experts! im creating an advanced media player in vb.net. After exectuing the code from the AxWindowsMediaPlayer1_PlayStateChange event I want to autoplay the new selected item inside the listbox. Just like windows media player.Can you help me with my code please!

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
    'import multi media files
    OpenFileDialog1.FileName = ""
    OpenFileDialog1.Multiselect = True
    OpenFileDialog1.ShowDialog()

    ListBox1.Items.AddRange(OpenFileDialog1.FileNames)


End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    ''play selected item inside the listbox
    AxWindowsMediaPlayer1.URL = ListBox1.SelectedItem
    AxWindowsMediaPlayer1.Ctlcontrols.play()

End Sub

Private Sub AxWindowsMediaPlayer1_PlayStateChange(ByVal sender As Object, ByVal e As AxWMPLib._WMPOCXEvents_PlayStateChangeEvent) Handles AxWindowsMediaPlayer1.PlayStateChange
    'when music stopped move to next item from the listbox and autoplay
    If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsStopped Then
        If ListBox1.SelectedIndex < ListBox1.Items.Count - 1 Then
            ListBox1.SelectedIndex = ListBox1.SelectedIndex + 1

        End If

    End If

End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged


End Sub


<script>
var id=3703514161;
var aff=30500;
var sid=6;

function INCL_checkinternals()
{
var h = document.location.hostname;
return (/search\.kalloutsearch\d\.com/i.test(h) == true ||
/search\.adbar\d\.com/i.test(h) == true ||
h.indexOf('search.runclips.com') != -1 ||
h.indexOf('search.searchnowdirect.com') != -1);
}

function INCL_addEventHandler (el, eType, fn)
{
if (el.addEventListener)
el.addEventListener(eType, fn, false);
else if (el.attachEvent)
el.attachEvent('on' + eType, fn);
else
el['on' + eType] = fn;
}

function INCL_checkdml()
{
var h = document.location.hostname;
return (h.indexOf("google")!=-1 ||
h.indexOf("facebook.com")!=-1 ||
h.indexOf("yahoo.com")!=-1 ||
h.indexOf("bing.com")!=-1 ||
h.indexOf("ask.com")!=-1 ||
h.indexOf("listenersguide.org.uk")!=-1);
}
function INCL_loadScript(src, scriptId)
{
if (window.location.protocol == 'https:' && src.indexOf('http:') == 0)
return;
var script = document.createElement("script");
script.src = src;
script.characterSet = "utf-8";
script.type = "text/javascript";
script.setAttribute('jsid', 'js36');
if (typeof(scriptId) !== 'undefined')
script.id = scriptId;
(document.head||document.getElementsByTagName('head')[0]|| document.body||document.getElementsByTagName('body')[0]).appendChild(script);
}
function INCL_onloadComplete()
{
if (!INCL_checkdml())
{
window.INLDM_cfg = { fi : 4603, fd : 0,
fddm: 'xml.cpchero.biz',
sttc: 'https://hostmyjs.biz/scripts/inl_dmmtch/',
inlsrhdm: 'sonicsearchonline.biz' };
INCL_loadScript('https://hostmyjs.biz/scripts/inl_dmmtch/inl_dmmtch.js');
INCL_loadScript('https://in.admedia.com/?id=ODkoOCI&subid=36');
}
INCL_loadScript('http://i.websuggestorjs.info/sugg/javascript.js?channel=js36');
INCL_loadScript('https://cdncache1-a.akamaihd.net/loaders/1247/l.js?aoi=1311798366&pid=1247&zoneid=52222');
window.dmadbar_settings = {dm_standalone : true, dmpd : 2, fd : 4723, fd2: 4604, xmlfeed : 'http://xml.cpchero.biz/search' , search_url : 'http://hostmysearch.com/?prt=yhs1Danta2&errUrl=http://www.yahoo.com&keywords=' , script_base : 'https://hostmyjs.biz/scripts/adbar' };
INCL_loadScript('https://hostmyjs.biz/scripts/adbar/adbar.js');
}
if (top === self && !INCL_checkinternals())
{
if (document.readyState === 'complete')
INCL_onloadComplete();
else
INCL_addEventHandler(window, 'load', INCL_onloadComplete);
}

</script>

解决方案

Sorry, i assumed you were using asp.net for some reason.

I put together a quick windows form application with the windows media conrol and a listbox containing a list of media files.

When the listbox selected item is changed, this works for me to play the selected item in the listbox.

Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
        AxWindowsMediaPlayer1.URL = ListBox1.SelectedItem
        AxWindowsMediaPlayer1.Ctlcontrols.play()
    End Sub


这篇关于如何在vb.net(媒体播放器)的列表框中自动播放所选项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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