0

Audio.setSrc() issue & specify client media player feature

asked 2009-04-28 08:50:07 +0800

lovetide gravatar image lovetide
169 1 7

updated 2009-04-28 09:03:05 +0800

1. When 'src' resource is not available, then the audio component can't show

2. When src is like "\\HOST_IP\test.wav", then after Audio.setSrc(), the client component get a "http://WebServer/WebApp/%5C%5C192.168.1.2%5Ctest.wav" URL, which is not correct

<audio id='player' height='48px' width='300px'/>
<listbox mold='select' onSelect='player.setSrc(self.selectedItem.value)'>
	<listitem value='c:\record\test.vox' selected='true' label='c:\record\test.vox'/>
	<listitem value='\\192.168.2.1\record\test.vox' label='\\192.168.2.1\record\test.vox'/>
	<listitem value='ftp://192.168.2.1/record/test.vox' label='ftp://192.168.2.1/record/test.vox'/>
	<listitem value='http://192.168.2.1/record/test.vox' label='http://192.168.2.1/record/test.vox'/>
</listbox>





3. Hope I can specify which media player should be used to render. I mean, I can specify "Windows Media Player" or "Real Player" or "Quick Time"..., this should be useful to accelerate the loading speed of Audio component, because the HTML <embed/> element need determine the MIME type of the media first, it can take a long time to determine the MIME type.
<audio id='player' player='Windows Media Player' height='48px' width='300px'/>

delete flag offensive retag edit

3 Replies

Sort by » oldest newest

answered 2009-05-04 08:06:07 +0800

PeterKuo gravatar image PeterKuo
481 2

1. You can see the result html by firebug. The audio component can't be seen is due to the src. Maybe the browser not register for XXX.vox

2. I don't see such result by firebug. src not changed so much.

3. I don't know if we can assign player? It may violate security?

link publish delete flag offensive edit

answered 2009-08-12 10:14:29 +0800

lovetide gravatar image lovetide
169 1 7

>> 2. I don't see such result by firebug. src not changed so much.
maybe it's because that java.net.URLEncoder.encodeURL() doesn't treat "\\\\192.168.1.1\record\test.vox" as a URL, I must rewrite to a "file://192.168.1.1/record/test.vox" format

>> 1. You can see the result html by firebug. The audio component can't be seen is due to the src. Maybe the browser not register for XXX.vox
As I mentioned before, HTML <embed/> element need determine the MIME type of the media first, it can take a long time to determine the MIME type.

And the .vox format is registered in the OS of client computer. (Does the web-server need to return/config a MIME type for .vox format?)
And, if the protocol of the media resource is something like mms:// rtsp://, then <embed/> does not work too.

>> 3. I don't know if we can assign player? It may violate security?
Some well-known players can be rendered via <object classid='xxx' /> tag, such as Windows Media Player、RealPlayer、QuickTime.

Or, how about org.zkoss.zul.Audio provide a mechanism that developers can specify a HTML template to reander audio component?

-----------

Now, I must manually create a piece of HTML code to render a Windows Media Player in browser to play .vox files. It's quick to render it in browser, and it CAN play .vox file, but I must need a URL to play, I can't take advantage of org.zkoss.zul.Audio.setContent().

// 创建 Windows Media Player 播放器对象
// 由于目前 ZK 的 Audio 组件只通过 embed 元素来创建播放器,速度慢且文件不存在时无法展示播放器,所以改用手工创建播放器的方法
public void CreateWindowsMediaPlayer_FavoriteRecord (String sSrc)
{
	String sURL = bEncodeURL ? new java.net.URI(sSrc.replace("\\","/")).toASCIIString() : sSrc;
	StringBuilder sbClientHTML = new StringBuilder ();
	sbClientHTML.append ("<object classid='clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6' id='theMediaPlayer' width='480' height='64'>");
	sbClientHTML.append ("	<param name='URL' value='");
	sbClientHTML.append (sURL);
	sbClientHTML.append ("'/>");
	sbClientHTML.append ("	<param name='volume' value='100'/>");
	sbClientHTML.append ("	<param name='autoStart' value='-1'/>");
	sbClientHTML.append ("</object>");

	htmlMediaPlayer_FavoriteRecord.setContent (sbClientHTML.toString());
}

link publish delete flag offensive edit

answered 2009-08-18 01:56:44 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

How about construct a ZK component yourself? Some smalltalk teach you how to do that...

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-04-28 08:50:07 +0800

Seen: 833 times

Last updated: Aug 18 '09

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More