GithubHelp home page GithubHelp logo

bkk0711 / musicplayer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from monokaijs/musicplayer

0.0 1.0 0.0 4 MB

Home Page: https://bkk0711.github.io/MusicPlayer/

HTML 16.11% JavaScript 47.16% CSS 36.73%

musicplayer's Introduction

MusicPlayer

-NOTE: Nếu muốn sửa nhạc, chỉ cần sửa variable songs(Array) theo dạng sau:

    artist: "Ca si 1",      // Tên Ca sĩ
    name: "Ten bai hat 1",  // Tên Bài hát
    url: "Link Nhac 1",     // Link file nhạc (flac, wav, mp3, ...)
    picture: "Link Anh 1"   // Link ảnh hiển thị (vuông)
}, {
    artist: "Ca si 2",
    name: "Ten bai hat 2",
    url: "Link Nhac 2",
    picture: "Link Anh 2"
}, ... ]

*Về Javascript, ở đây có các Functions sau:

  • shuffle
  • playPause
  • showHover
  • playFromClickedPos
  • checkBuffering
  • selectTrack
  • initPlayer
  • Hàm Shuffle: Hàm này sẽ xáo thứ tự các item trong 1 Array theo thứ tự ngẫu nhiên. (Dành cho bạn nào muốn Xáo cái list nhạc trước khi nghe).
  • Hàm playPause: Hàm này Handle event click vào nút Play/Pause. (Dừng nhạc / tiếp tục phát từ điểm dừng cuối cùng).
  • Hàm showHover: Ở đây hàm này sẽ chịu trách nhiệm cho event click vào thanh trượt hiển thị thời lượng % bài nhạc đã phát (Click để phát từ chỗ vừa click chuột). Khi click, 1 argument được truyền vào là thông tin của cái event. Trong Event này bao gồm vị trí click chuột (Event.clientX là vị trí chuột tính theo chiều ngang của web (Mục đích tìm xem chuột di vào vị trí nào mà tính thời gian)). seekT chính là khoảng cách từ điểm bắt đầu của thanh hiển thị tới điểm của chuột. seekLoc là giá trị tính bằng giây. Hàm này sẽ bị GỌI LIÊN TỤC khi chuột hover trên thanh trượt. (Mục đích là để set giá trị)-
  • Hàm hideHover: Chuột đi ra khỏi thanh trượt sẽ gọi event này. Mục đích là để set lại cái dải hiển thị phần chuột đã select (từ điểm bắt đầu tới vị trí chuột) về điểm bắt đầu (sHover.width = 0). Ngoài ra event này cũng set các text đếm thời gian về điểm bắt đầu.
  • Hàm updateCurrTime: Gọi để set thời gian, nếu đủ 100% (hết bài) thì chuyển bài và set thời gian về bắt đầu.
  • Hàm checkBuffering: Kiểm tra nhạc đã load xong chưa. Hàm selectTrack: Chuyển bài (tiến/lùi). Thực chất chỉ là tăng giảm biến currIndex và set các giá trị theo currIndex.
  • Hàm initPlayer: Bắt đầu player và gán tuần tự các events.

musicplayer's People

Contributors

monokaijs avatar bkk0711 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.