Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
&引用;“深度链接”;在使用HTML5/Flash的MP3中的特定位置_Flash_Html_Mp3_Audio Streaming - Fatal编程技术网

&引用;“深度链接”;在使用HTML5/Flash的MP3中的特定位置

&引用;“深度链接”;在使用HTML5/Flash的MP3中的特定位置,flash,html,mp3,audio-streaming,Flash,Html,Mp3,Audio Streaming,是否有任何现有的代码示例,可以按照YouTube上发生的类似操作进行操作,从而可以“深度链接”到视频中的某个位置,而不是MP3 例如,作为如何在YouTube上实现这一点的示例,正常链接是: 可以在特定时间用鼠标右键单击播放位置图标,然后选择“在当前时间复制视频URL”,例如,在14秒时选择并获得如下链接: 我想通过深度链接到我想在网页上播放的MP3来做同样的事情 我见过一些HTML5 MP3播放器,比如Jplayer(http://www.jplayer.org),但我还没有看到它提供的这

是否有任何现有的代码示例,可以按照YouTube上发生的类似操作进行操作,从而可以“深度链接”到视频中的某个位置,而不是MP3

例如,作为如何在YouTube上实现这一点的示例,正常链接是:

可以在特定时间用鼠标右键单击播放位置图标,然后选择“在当前时间复制视频URL”,例如,在14秒时选择并获得如下链接:

我想通过深度链接到我想在网页上播放的MP3来做同样的事情

我见过一些HTML5 MP3播放器,比如Jplayer(http://www.jplayer.org),但我还没有看到它提供的这种功能

有什么线索、提示、建议可以这样开始实现吗?我想我更喜欢使用HTML5,但是我会考虑Flash。 更新(11/01/2012): 当我单击“单击我”时,我得到的“TypeError:“null”不是对象(计算“music.currentTime=att_hash['a']”)按钮

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<!-- Website Design By: www.happyworm.com -->
<title>Demo : jPlayer as an audio player</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="http://www.jplayer.org/latest/skin/blue.monday/jplayer.blue.monday.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>
<script type="text/javascript" src="http://www.jplayer.org/latest/js/jquery.jplayer.min.js"></script>
<script type="text/javascript">
//<![CDATA[
$(document).ready(function(){
$("#jquery_jplayer_1").jPlayer({
ready: function (event) {
$(this).jPlayer("setMedia", {
m4a:"http://www.jplayer.org/audio/m4a/TSP-01-Cro_magnon_man.m4a"
});
},
swfPath: "js",
supplied: "m4a, oga",
wmode: "window"
});
});
//]]>
</script>
</head>
<body>
<div id="jquery_jplayer_1" class="jp-jplayer"></div>
<div id="jp_container_1" class="jp-audio">
<div class="jp-type-single">
<div class="jp-gui jp-interface">
<ul class="jp-controls">
<li><a href="javascript:;" class="jp-play" tabindex="1">play</a></li>
<li><a href="javascript:;" class="jp-pause" tabindex="1">pause</a></li>
<li><a href="javascript:;" class="jp-stop" tabindex="1">stop</a></li>
<li><a href="javascript:;" class="jp-mute" tabindex="1" title="mute">mute</a></li>
<li><a href="javascript:;" class="jp-unmute" tabindex="1" title="unmute">unmute</a></li>
<li><a href="javascript:;" class="jp-volume-max" tabindex="1" title="max volume">max volume</a></li>
</ul>
<div class="jp-progress">
<div class="jp-seek-bar">
<div class="jp-play-bar"></div>
</div>
</div>
<div class="jp-volume-bar">
<div class="jp-volume-bar-value"></div>
</div>
<div class="jp-time-holder">
<div class="jp-current-time"></div>
<div class="jp-duration"></div>
<ul class="jp-toggles">
<li><a href="javascript:;" class="jp-repeat" tabindex="1" title="repeat">repeat</a></li>
<li><a href="javascript:;" class="jp-repeat-off" tabindex="1" title="repeat off">repeat off</a></li>
</ul>
</div>
</div>
<div class="jp-title">
<ul>
<li>A Song</li>
</ul>
</div>
<div class="jp-no-solution">
<span>Update Required</span>
To play the media you will need to either update your browser to a recent version or update your <a href="http://get.adobe.com/flashplayer/" target="_blank">Flash plugin</a>.
</div>
</div>
</div>
<br><br>
<button id="gettime">Click Me!</button>
<input type="text" id="showtime">
<script language="javascript">                    
var music = document.getElementById('music') // Your <audio> object
var gettime = document.getElementById('gettime') // A 'get time' button
var showtime = document.getElementById('showtime') // An input text object for displaying the URL
gettime.addEventListener("click", function(){
showtime.value = window.location.protocol+'//'+window.location.host+window.location.pathname+'?a='+music.currentTime;
}, true);
window.addEventListener('load', function(){
var att_hash = get_url_variables()
if (att_hash) {
music.currentTime = att_hash['a']
}
}, true);
function get_url_variables() {
var att_hash = []
var var_array = window.location.search.split(/[\?&]/)
for (i=0; i<var_array.length; i++) {
if (var_array[i] != "") {
var att_var = var_array[i].split("=",2)
att_hash[att_var[0]]=att_var[1]
}
}
return att_hash;
}
</script>
</body>
</html>

演示:jPlayer作为音频播放器
//
  • 一首歌
需要更新 要播放媒体,您需要将浏览器更新为最新版本,或更新浏览器。

点击我! var music=document.getElementById('music')//您的对象 var gettime=document.getElementById('gettime')//一个“获取时间”按钮 var showtime=document.getElementById('showtime')//用于显示URL的输入文本对象 addEventListener(“单击”,函数(){ showtime.value=window.location.protocol+'/'+window.location.host+window.location.pathname+'-a='+music.currentTime; },对); addEventListener('load',function()){ var att_hash=get_url_variables() if(att_hash){ music.currentTime=att_hash['a'] } },对); 函数get_url_variables(){ var att_hash=[] var var\u array=window.location.search.split(/[\?&]/)
对于(i=0;i使用HTML5/javascript实现您想要的最大问题是它不提供对剪贴板的访问。但是,如果您不介意为用户提供手动复制的URL,那么这相当容易实现。据我所知,如果您想写入用户的剪贴板,您需要使用类似flash的帮助不过我没有闪光经验,所以在这里帮不了你

audio对象提供了float currentTime,可以轻松设置或检索。同时,您可以检索URL和相关变量,并使用各种函数。在这里,我编写了函数get_URL_variables,将它们传递到散列中。如果您使用的是jquery之类的库,我强烈怀疑它提供了类似的功能,并且可能比我的快速示例要稳定得多

编辑:哎呀,我错过了你要求的右键菜单。我从来都不是这个的超级粉丝,但是有关于这个的讨论

var music=document.getElementById('music')//您的对象
var gettime=document.getElementById('gettime')//一个“获取时间”按钮
var showtime=document.getElementById('showtime')//用于显示URL的输入文本对象
addEventListener(“单击”,函数(){
showtime.value=window.location.protocol+'/'+window.location.host+window.location.pathname+'-a='+music.currentTime;
},对);
addEventListener('load',function()){
var att_hash=get_url_variables()
if(att_hash){
music.currentTime=att_hash['a']
}
},对);
函数get_url_variables(){
var att_hash=[]
var var\u array=window.location.search.split(/[\?&]/)

对于(i=0;我非常感谢您的反馈。抱歉,作为一名试图学习Javascript/HTML5的PHP开发人员,这完全超出了我的理解范围-对于如何学习如何集成这样的东西,有什么建议吗?对于一个好的资源,我并不是最好的提问者,因为我的一般方法是使用多个资源,然后随着我理解能力的提高,完善我的方法。了解上述内容的一个好起点是确保您了解document.getElementById('music')位所做的事情,以及object.addEventListener位。(编辑:过早按enter键)另外,我应该指出,我上面的例子并不好,因为它创建了大量不必要的全局变量。而且,就目前而言,它只能处理一个音频对象和相关按钮。我刚刚纠正了示例代码中的一个错误,如果URL中没有定义GET属性,则音频位置被设置为“undefined”。谢谢您的帮助e回复。我想对我来说,挑战性的事情是我甚至不知道从哪里开始。除了上面显示的源代码之外,我还需要向我的页面添加哪些其他项目?我假设我必须在页面的某个地方添加一个按钮-但我还不完全确定从哪里开始。好的,我添加了我认为应该添加的内容感谢@james-g
var music = document.getElementById('music') // Your <audio> object
var gettime = document.getElementById('gettime') // A 'get time' button
var showtime = document.getElementById('showtime') // An input text object for displaying the URL

gettime.addEventListener("click", function(){
        showtime.value = window.location.protocol+'//'+window.location.host+window.location.pathname+'?a='+music.currentTime;
    }, true);

window.addEventListener('load', function(){
        var att_hash = get_url_variables()
        if (att_hash) {
            music.currentTime = att_hash['a']
        }
    }, true);

function get_url_variables() {
    var att_hash = []
    var var_array = window.location.search.split(/[\?&]/)
    for (i=0; i<var_array.length; i++) {
        if (var_array[i] != "") {
            var att_var = var_array[i].split("=",2)
            att_hash[att_var[0]]=att_var[1]
        }
    }
    return att_hash;
}