Jump to content

Ignition: play and stop a song ...


Curanai

Recommended Posts

Hi everyone, dear Admin and devs,
 
I was rumming on Ignition, searching a song of one or two bands. Suddenly I rememberd a song heard on my web radio and found a huge list of this band. Pressing the play-button in front is comfortable - pressing F5 to reload the whole search result to stop this song playing is not! ;)
 
Pressing stop/pause calls this method: pause_Video('[number]', this, ytPlayer_[number]);
 
The method itself calls player.pauseVideo(); and especially this method is not a function (reported on console; file: common.js line 185:9).
 
Pls, I would appreciate a functional stop-/replay-button! :D Because it's bugged ...
 
So, I opened Ignition and sorted by most downloaded songs - for this demo I've chosen "Nirvana".
 
I almost adopted your current system, but using only jQuery.
 

recordID = 2117; // your record ID; e. g. Nirvana - Smells like teen spirit
if ($('#yt_'+recordID+'-playbutton').is(':visible')) {
  $('#yt_'+recordID+'-playbutton').click(); // this causes message in browser against auto-play
} else {
  $('#yt_'+recordID+' object').replaceWith('<div id="videoDiv_'+recordID+'" class="ytPlayer"></div>');
}
$('#yt_'+recordID+'-playbutton, #yt_'+recordID+'-pausebutton').toggle(); // switching play/pause button in visual

If you use this in console, you will have a message in your browser because of "click()" in first condition - I am using your attribute of an event handler. So, pls accept auto-play in this test. ;)
 
Well, "Smells like teen spirit" starts playing ... firing same script in console will stop (!) the song and set the icons back. Pressing play again, song starts again ... and so on.

Suggestion: Ignition would be faster, if not every part of a row have an repeated event listener for the same job (showing info box) - use the parent (the row itself) instead and define the action (showing modal or play/stop). Better use: functions like play/pause get their own column, so you can use an event listener for the info box on Artist, Title and Album without conflicting another event listener (play/stop).

Two things to handle in your common.js with this solution above:
- remove toggleButtonPlayer(buttonobj) from the lines and as a function (why mixing regular JS with jQuery?!)
- remove player.pauseVideo() (useless and throws errors)
 
it's even possible to remind the current playing song - but not in global scope of your current coding. Pls, think about object notation - so if another song is started, currently running one could be stopped. And this is what I call comfortably. :D
 
And why you are using each song an ytplayer-DIV?! Use just one!
 
Well, easy enough ... probably like this (untested):

let ignition = {
	playing: 0,
	
	btns: [
		'<i class="fas fa-play" alt="Click to listen" title="Click here to listen to the song"></i>',
		'<i class="fas fa-pause" alt="Pause playback" title="Pause playback"></i>'
	],
	
	nowListen: function(i, yt){
		// first stop ...
		if(ignition.playing > 0) {
			ignition.stop(ignition.playing);
			ignition.btnChange(ignition.playing, 0);
		}
		
		if (i != ignition.playing) {
			ignition.playing = parseInt(i, 10);
		
			if (ignition.playing > 0) {
				ignition.play(i, yt);
			}
		}
	},
	
	play: function(i, yt) {
		if(yt.length > 0) {
			yt = yt.replace('http://youtu.be/', '');
		}
		
		swfobject.embedSWF(
			'http://www.youtube.com/v/' + yt + 
			'?version=3' + 
			'&enablejsapi=1' + 
			'&playerapiid=player1' + 
			'&hd=1' + 
			'&loop=0' + 
			'&autoplay=1', 
			'myCurrentlySongIamListening', 
			'300', 
			'300', 
			'9', 
			null, 
			null, 
			{
				allowScriptAccess: 'always'
			}, 
			{
				id:'myCurrentlySongIamListening', 
				class: 'ytPlayer'
			}
		);
		
		ignition.btnChange(i, 1);
	},
	
	stop: function(i) {
		$('#myCurrentlySongIamListening object').remove();
	},
	
	btnChange: function(i, state){
		$('.btn'+i).html(ignition.btns[state]);
	}
};

// use only ONE div for playing audio ... put this into footer or similar, but outside data table!
// <div id="myCurrentlySongIamListening" class="ytPlayer"></div>

// a link with Nirvana ...
// <a class="btn2117" href="javascript:ignition.nowListen(2117, 'hTWKbfoikeg')" title="..."><i class="fas fa-play" alt="Click to listen" title="Click here to listen to the song"></i></a>


Pls, this is no criticism - just my two cents to make this a little bit better for all of us. I don't want just to say, what should be done - more like how in advice. ;)

Many thanks for reading and keep up your work here!
 
Best regards.

  • Like 1
Link to comment
Share on other sites

  • Administrator

Thanks for this. This has been a long broken feature that will be fixed on the new ignition. We're not really fixing anything on old ignition unless it is super critical. If you want to check on how I4 does it just PM me on discord and I'll set you up with early pre-alpha access ;)

"Just remember: when something breaks, kick it as hard as you fucking can"

-Trent Reznor
Support Me (Via Patreon)

Link to comment
Share on other sites

  • 1 month later...

Hi, thanks for your offer and trust having a look at I4. You will do I4 very well - just keep this feature above in mind. After a release I will have a look at it and send you tickets/reports/hints/suggestions. ;) Keep healthy and bye.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

By using this site, you agree to our Guidelines. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. - Privacy Policy