0 votes
by (2.5k points)
edited by
<iframe width="1" height="1" src="https://www.youtube.com/embed/zNd4apsr3WE?autoplay=1" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>

How do I make this continue playing dispite switching passages and stop on a passage I set it to.

And if I can't, is there a way I can still use embed youtube video to? Neocity will not let me upload mp3 files.

I'm starting to get desparate...

 

HALP ME GRAYELF!  "I LOVE UUUUUUUUUU."~Jontron 'Last episode of Sonic '06'

 

https://twinery.org/forum/discussion/6211/stretching-youtube-video-over-multiple-passges-or-embedding-in-stylesheet (same, unanswered question on the old forum)

 

Update: Found a website that will help me out, still having and issue getting the music to play ONLY on passages I need it too. http://www.ohiofi.com/blog/twine-music-and-sound-effects-from-youtube

Update: Why doesn't this work???

if(typeof YouTubeTunes == "undefined"){
$('body').append('<div id="youtubetunes"></div>');
var YouTubeTunes = {
play: function(id){
console.log('YouTubeTunes:' + id);
if(this.current != id){
this.current = id;
var container = $('#youtubetunes');
container.empty();
container.append('<iframe src="https://youtube.com/embed/' + id +
'?autoplay=1&amp;loop=1&amp;playlist='+ id +
'" style="visibility:hidden;width:500px;height:500px;position:absolute;top:-1000px;left:-1000px;"></iframe>');
} else {
console.log('already playing');}},
stop: function(){
$('#youtubetunes').empty();
this.current = "";
console.log('stopped youtubetunes');}};
window.YouTubeTunes = YouTubeTunes;}

 

1 Answer

+1 vote
by (2.5k points)
 
Best answer

Solution: OK GUYS I FOUND OUT HOW TO DO IT MYSELF. NO HELP TO Y'ALL(im messing with y'all I stil luv yah)

Here is my solution

if(typeof YouTubeTunes == "undefined"){

$('body').append('<div id="youtubetunes"></div>');

var YouTubeTunes = {

    play: function(id){

        console.log('YouTubeTunes:' + id);

        if(this.current != id){

            this.current = id;

            var container = $('#youtubetunes');

            container.empty();

            container.append('<iframe width="1" height="1" src="https://www.youtube.com/embed/'+id+'?rel=0&autoplay=1&controls=0&showinfo=0&loop=1&playlist='+id+'" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen ></iframe>');

        } else {

            console.log('already playing');

        }

    },

    stop: function(){

        $('#youtubetunes').empty();

        this.current = "";

        console.log('stopped youtubetunes');

    }

};

window.YouTubeTunes = YouTubeTunes;

}

Put this in your java script.

Then...

<div style="display: none;"><img src="!@#$" onerror="YouTubeTunes.play('WHAT EVER YOUR VIDEO ID IS');" /></div>

Put this in the passage you want the music to play in...(put it at the bottom or it will mess up your screen)

THEN....

<div style="display: none;"><img src="!@#$" onerror="YouTubeTunes.stop('');" /></div>

Put this in what ever passage you want it to stop in...

Hope this helps many people in the future...

by (63.1k points)
edited by
I'm not sure why you are hot linking a YouTube video for sound. That's a massive waste of bandwidth. Back before reliable ways to host audio online, that was recommended for Twine 1 sometimes, but it wasn't really a good solution then either.

You would generally be better off using one of my premade audio libraries for Harlowe, or using the web audio API and doing it yourself.

Example of the web audio API being used in harlowe:

https://twinery.org/questions/24745/enable-background-audio-only-on-active-window

My audio libraries.

https://twinelab.net/harlowe-audio

https://github.com/ChapelR/howler-for-harlowe
...