JWPlayer处理youtube错误(JWPlayer handle youtube errors)
我想处理JWPlayer中的youtube错误,所以如果视频不存在或者国家/地区无法在播放器上显示消息,或者使用javascript,我正在做这样的事情......
var options = { height: 330, }, flashplayer: '/player.swf', width: 560, events:{ onError:function(obj){ alert('ERROR'+obj); } } , debug: 'console' }; jwplayer("player").setup(options); jwplayer("player").play();
但它没有从onError事件进入内部,即使视频甚至不存在......我可以在控制台中看到.. LOG(加载预览图像时出错:错误#2036)
在youtubes限制国家的情况下,我甚至无法在控制台中看到它。
在任何情况下,视频只显示加载动画,它使用户相信它可以在任何时间加载,这不是真的。
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets">
<script type="text/javascript" src="#{facesContext.externalContext.requestContextPath}/assets/jwplayer.min.js"></script> <script type="text/javascript" src="#{facesContext.externalContext.requestContextPath}/assets/swfobject.js"></script>
<div id="player"></div> </body> <script type="text/javascript"> //<![CDATA[ window.onload=createPlayer(); function createPlayer() { var flashvars = { file:"http://www.youtube.com/watch?v=pnEHsUWFuNM", autostart:"true" } var params = { allowfullscreen:"true", allowscriptaccess:"always" } var attributes = { id:"player1", name:"player1" } swfobject.embedSWF("#{facesContext.externalContext.requestContextPath}/assets/player.swf", "player", "320", "196", "9.0.115", false, flashvars, params, attributes); } function loadPlayer() { var options = { height: 325, flashplayer: '#{facesContext.externalContext.requestContextPath}/assets/player.swf', width: 560, events:{ onError:function(error){ alert('Error loading your link, please try another one'); } } /* , debug: 'console'*/ }; options.file = 'http://www.youtube.com/watch?v=pnEHsUWFuNM'; options.events.onReady= function(){ jwplayer("player").play(); }; jwplayer("player").setup(options); } //]]> </script>
loadPlayer直接从SWFObject尝试使用jwplayer.js和createPlayer ...该视频只是存在于德国不应该显示,仍然试图加载它。 如果我设置任何其他未显示的URL,请说“ http://www.youtube.com/watch?v=ABC ”仍然一直尝试加载未显示的视频。
I would like to handle the youtube errors in the JWPlayer, so in case the video doesn't exists or is not available for the country show a message on the player, or with javascript, i am doing something like this...
var options = { height: 330, }, flashplayer: '/player.swf', width: 560, events:{ onError:function(obj){ alert('ERROR'+obj); } } , debug: 'console' }; jwplayer("player").setup(options); jwplayer("player").play();
but its not getting inside from the onError event, even though the video doesnt even exist... and i can see in the console.. LOG (Error loading preview image: Error #2036)
In the case of youtubes restriction country i cannot even see that in the console.
In any case the video just show the loading animation, which it makes belieave the user that it can be load in any time, which its not true.
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets">
<script type="text/javascript" src="#{facesContext.externalContext.requestContextPath}/assets/jwplayer.min.js"></script> <script type="text/javascript" src="#{facesContext.externalContext.requestContextPath}/assets/swfobject.js"></script>
<div id="player"></div> </body> <script type="text/javascript"> //<![CDATA[ window.onload=createPlayer(); function createPlayer() { var flashvars = { file:"http://www.youtube.com/watch?v=pnEHsUWFuNM", autostart:"true" } var params = { allowfullscreen:"true", allowscriptaccess:"always" } var attributes = { id:"player1", name:"player1" } swfobject.embedSWF("#{facesContext.externalContext.requestContextPath}/assets/player.swf", "player", "320", "196", "9.0.115", false, flashvars, params, attributes); } function loadPlayer() { var options = { height: 325, flashplayer: '#{facesContext.externalContext.requestContextPath}/assets/player.swf', width: 560, events:{ onError:function(error){ alert('Error loading your link, please try another one'); } } /* , debug: 'console'*/ }; options.file = 'http://www.youtube.com/watch?v=pnEHsUWFuNM'; options.events.onReady= function(){ jwplayer("player").play(); }; jwplayer("player").setup(options); } //]]> </script>
loadPlayer to try with jwplayer.js and the createPlayer directly from SWFObject... that video exist just that it shouldnt be shown in germany, still its trying to load it. and if i set any other unexisting URL let say "http://www.youtube.com/watch?v=ABC" still keeps trying to load the unexisting video.
原文:https://stackoverflow.com/questions/16960779
最满意答案
为了分别在x和y轴上绘制波长和强度,每个不同的晶圆编号,就像它自己的系列一样,可以将数据
wafer_number
,然后处理每个组import pandas as pd from StringIO import StringIO import matplotlib.pyplot as plt data = \ """wafer_number,test_type,test_pass,x_coord,y_coord,test_el_id,wavelength,intensity HT2731,T2,1,38,54,24,288.68,4413 HT2731,T2,1,40,54,25,257.42,2595 HT2731,T2,1,50,54,28,300.00,2836 HT2731,T2,1,52,54,29,300.00,2862 HT2731,T2,1,54,54,30,300.00,3145 HT2731,T2,1,56,54,31,300.00,2804 HT2731,T2,1,58,54,32,255.69,2803 HT2731,T2,1,59,54,33,257.23,2991 HT2731,T2,1,60,54,34,262.45,3946 HT2731,T2,1,62,54,35,291.84,9398 HT2801,T2,1,38,55,54,288.68,4125 HT2801,T2,1,38,56,55,265.25,4258""" df = pd.read_csv(StringIO(data),sep = ',') dfg = df.groupby('wafer_number') colors = 'bgrcmyk' fig, ax = plt.subplots() for i,k in enumerate(dfg.groups.keys()): currentGroup = df.loc[dfg.groups[k]] color = colors[i % len(colors)] ax.plot(currentGroup['wavelength'].values,currentGroup['intensity'].values,\ ls='', color = color, label = k, marker = 'o', markersize = 8) legend = ax.legend(loc='upper center', shadow=True) plt.xlabel('wavelength') plt.ylabel('intensity') plt.show()
To plot wavelength and intensity on the x and y axes respectively with each different wafer number as it's own series, one can group data wrt
wafer_number
, and then deal with each groupimport pandas as pd from StringIO import StringIO import matplotlib.pyplot as plt data = \ """wafer_number,test_type,test_pass,x_coord,y_coord,test_el_id,wavelength,intensity HT2731,T2,1,38,54,24,288.68,4413 HT2731,T2,1,40,54,25,257.42,2595 HT2731,T2,1,50,54,28,300.00,2836 HT2731,T2,1,52,54,29,300.00,2862 HT2731,T2,1,54,54,30,300.00,3145 HT2731,T2,1,56,54,31,300.00,2804 HT2731,T2,1,58,54,32,255.69,2803 HT2731,T2,1,59,54,33,257.23,2991 HT2731,T2,1,60,54,34,262.45,3946 HT2731,T2,1,62,54,35,291.84,9398 HT2801,T2,1,38,55,54,288.68,4125 HT2801,T2,1,38,56,55,265.25,4258""" df = pd.read_csv(StringIO(data),sep = ',') dfg = df.groupby('wafer_number') colors = 'bgrcmyk' fig, ax = plt.subplots() for i,k in enumerate(dfg.groups.keys()): currentGroup = df.loc[dfg.groups[k]] color = colors[i % len(colors)] ax.plot(currentGroup['wavelength'].values,currentGroup['intensity'].values,\ ls='', color = color, label = k, marker = 'o', markersize = 8) legend = ax.legend(loc='upper center', shadow=True) plt.xlabel('wavelength') plt.ylabel('intensity') plt.show()
相关问答
更多-
实时绘制熊猫数据帧(realtime plotting pandas dataframe)[2022-03-10]
我认为您的代码的问题是每次刷新数据时都会调用fig, ax = plt.subplots() 。 这会每次创建一个新的Figure ,因此您会看到弹出的新框架。 相反,您希望在while循环外部创建Figure ,并且只在加载新数据后刷新Axes 。 我已经使用了您提供的基本示例来创建自我更新的Figure 。 import pandas as pd import matplotlib.pyplot as plt import datetime as dt data = [ {'timesta ... -
使用matplotlib 使用matplotlib,您可以为轴定义循环器以自动循环颜色和线型。 (见这个答案 )。 import numpy as np; np.random.seed(1) import pandas as pd import matplotlib.pyplot as plt f = lambda i: pd.DataFrame(np.cumsum(np.random.randn(20,3),0)) dic1= dict(zip(range(3), [f(i) for i in rang ...
-
刚刚得到它,'b'是对象类型而不是float64因为这一行:2015-01-23 NaN 1,4 just got it, 'b' is of object type and not float64 because of this line : 2015-01-23 NaN 1,4
-
首先filter并比较所有数据与A ,和True和最后减去B由rsub : a = df.filter(like='state').eq('A').sum(axis=1).rsub(3) #same as #a = 3 - (df.filter(like='state') == 'A').sum(axis=1) print (a) 0 3 1 2 2 1 3 0 4 2 dtype: int64 详情: print (df.filter(like='state')) st ...
-
np.array_split非常适合这个用例。 [40]: df = DataFrame(np.random.randn(5,10)) In [41]: df Out[41]: 0 1 2 3 4 5 6 7 8 9 0 -1.998163 -1.973708 0.461369 -0.575661 0.862534 -1.326168 ...
-
Pandas数据帧操作(Pandas dataframe manipulation)[2021-10-30]
这应该工作: >>> fn = lambda obj: obj[obj.status == 1] if any(obj.status == 1) else obj >>> df.groupby(['id', 'letter'], as_index=False).apply(fn) id letter status 5 0 a 1 1 1 b 1 2 2 c 0 4 3 b 0 [4 rows x ... -
必须调用plt.show() ,其中import matplotlib.pyplot as plt plt.show() must be called where import matplotlib.pyplot as plt
-
你可以使用crosstab pd.crosstab(df1.category,df1.letter) Out[554]: letter a b category bar 1 1 foo 2 0 spam 0 1 要修复代码,请添加unstack df1.groupby(['category','letter']).size().unstack(fill_value=0) Out[556]: letter a b category ...
-
为了分别在x和y轴上绘制波长和强度,每个不同的晶圆编号,就像它自己的系列一样,可以将数据wafer_number ,然后处理每个组 import pandas as pd from StringIO import StringIO import matplotlib.pyplot as plt data = \ """wafer_number,test_type,test_pass,x_coord,y_coord,test_el_id,wavelength,intensity HT2731,T2,1,38 ...
-
Pandas 0.17.1数据帧操作引用一列并写入csv(Pandas 0.17.1 dataframe manipulation refering a column and writen to csv)[2021-12-10]
尝试这个: data = pd.read_html(url, header=0)[0] 当你调用read_html时,你得到一个DataFrame的列表,你需要找出你想要的那个,上面的编辑将选择第一个,你可能想要查看所有这些。 try this: data = pd.read_html(url, header=0)[0] You get a list of DataFrame's back when you call read_html, you need to figure out which one ...