Jump to content

Media Player Yapma


Kral__
 Share

Recommended Posts

[b][font="Comic Sans MS"]Media Player Yapımı

~ Player ~

Global

[spoiler][code]function muzikcal(path)
Audio.Load(CHANNEL_BACKGROUND, path, true, false);

Page.StartTimer(500);
local tblSplit = String.SplitPath(path);
nLen = Audio.GetLength(CHANNEL_BACKGROUND)
Paragraph.SetText("sarkı", tblSplit.Filename);
tnctr=true
end[/code][/spoiler]
On Timer

[spoiler][code]if tnctr then
nCurPos = Audio.GetCurrentPos(CHANNEL_BACKGROUND);
nGetLength = Audio.GetLength(CHANNEL_BACKGROUND);
if Math.Round(nCurPos)== Math.Round(nGetLength) then
item = item + 1
itemdatasi = ListBox.GetItemData("list", item);
ListBox.DeselectItem("list", -1);
ListBox.SelectItem("list", item);
muzikcal(itemdatasi)
Application.Sleep(2000)
end
end[/code][/spoiler]
Next Butonu

[spoiler][code]item = item + 1
itemdatasi = ListBox.GetItemData("list", item);
ListBox.DeselectItem("list", -1);
ListBox.SelectItem("list", item);
ListBox.SetItemCheck("list", item, BST_CHECKED);
muzikcal(itemdatasi)[/code][/spoiler]
Prev

[spoiler][code]item = item - 1
itemdatasi = ListBox.GetItemData("list", item);
ListBox.DeselectItem("list", -1);
ListBox.SelectItem("list", item);
ListBox.SetItemCheck("list", item, BST_CHECKED);
muzikcal(itemdatasi)[/code][/spoiler]
Toplam Zamanı ve Şu Anki Zamanı Gösterme

Global

[spoiler][code]function SecondsToClock(sSeconds)
local nSeconds = String.ToNumber(sSeconds)
if nSeconds == 0 then

return "00:00";
else
local nMins = string.format("%02.f", Math.Floor(nSeconds/60));
local nSecs = string.format("%02.f", Math.Floor(nSeconds - nMins *60));
return nMins..":"..nSecs
end
end[/code][/spoiler]
On Timer

[spoiler][code]if tnctr then
nCurPos = Audio.GetCurrentPos(CHANNEL_BACKGROUND);
nGetLength = Audio.GetLength(CHANNEL_BACKGROUND);
Label.SetText("süre", SecondsToClock(nCurPos).. " / " ..SecondsToClock(nLen));
...... üstteki timerdaki kodların gerisini yazmanız yeterlidir.[/code][/spoiler]
Müzik Ekleme

Global

[spoiler][code]--çalma listesi oluştur
function CreatePlayList(list)
local count = ListBox.GetCount(list)
if (count>0) then
local tFile = Dialog.FileBrowse(false,"Dosya Kaydet",_DesktopFolder,"Çalma Listesi(*.m3u)|*.m3u|","","m3u",false,false);
if (tFile and tFile[1]~="CANCEL") then
local str = ""
for i=1,count do
str = str .. ListBox.GetItemData(list,i).."\r\n"
end
TextFile.WriteFromString(tFile[1],str,false);
end
else
Dialog.Message("Uyarı","Listede veri yok.");
end
end
--çalma listesini yükle
function LoadPlayList(list)
local tFile = Dialog.FileBrowse(true,"Dosya Kaydet",_DesktopFolder,"Çalma Listesi(*.m3u)|*.m3u|","","m3u",false,false);
if (tFile and tFile[1]~="CANCEL") then
local readTbl = TextFile.ReadToTable(tFile[1]);
if (readTbl) then
ListBox.SetUpdate(list,false);
for i=1,#readTbl do
local split = String.SplitPath(readTbl[i]);
ListBox.AddItem(list,split.Filename..split.Extension,readTbl[i]);
end

ListBox.SetUpdate(list,true);
end
end
end[/code][/spoiler]
Buton/On Click veya On Right Click

[spoiler][code] tblMenu = {};
tblMenu[5] ={};
tblMenu[5].Text = "Aç";
tblMenu[5].ID = 101;
tblMenu[5].IconID = 11;
tblMenu[5].Checked = false;
tblMenu[5].Enabled = true;

tblMenu[4] ={};
tblMenu[4].Text = "Kaydet";
tblMenu[4].ID = 102;
tblMenu[4].IconID = 11;
tblMenu[4].Checked = false;
tblMenu[4].Enabled = true;

tblMenu[1] ={};
tblMenu[1].Text = "Gözat";
tblMenu[1].ID = 104;
tblMenu[1].IconID = 11;
tblMenu[1].Checked = false;
tblMenu[1].Enabled = true;

tblMenu[3] ={};
tblMenu[3].Text = "Temizle";
tblMenu[3].ID = 100;
tblMenu[3].IconID = 11;
tblMenu[3].Checked = false;
tblMenu[3].Enabled = true;

tblMenu[2] ={};
tblMenu[2].Text = "Seçerek Aç";
tblMenu[2].ID = 105;
tblMenu[2].IconID = 11;
tblMenu[2].Checked = false;
tblMenu[2].Enabled = true;

ptMouse = System.GetMousePosition(false, nil);

nRes = Application.ShowPopupMenu(ptMouse.X, ptMouse.Y, tblMenu, TPM_RIGHTALIGN, TPM_TOPALIGN, true, false);

if(nRes == 100)then

Audio.Stop(CHANNEL_BACKGROUND);
ListBox.DeleteItem("list", -1);
Image.SetSize("play", 35, 35);
Image.SetSize("puase", 0, 0);
gerial()
elseif(nRes == 101)then

LoadPlayList("list")
elseif(nRes == 102)then
CreatePlayList("list")


elseif(nRes == 104)then

dosya = Dialog.FolderBrowse("Mp3 Klasörünü seçin", _DesktopFolder)
StatusDlg.Show(0, false);
tblFiles = File.Find(dosya, "*.mp3", true, false, nil, nil);
if tblFiles then
for i,v in pairs (tblFiles) do
local tblSplit = String.SplitPath(v)
ListBox.AddItem("list", tblSplit.Filename, v);
end
end
StatusDlg.Hide();
elseif(nRes == 105)then


dosya = Dialog.FileBrowse(true, "Müzik Seçiniz", _DesktopFolder, "Müzik (*.mp3)|*.mp3|", "", "dat", true, false);
StatusDlg.Show(0, false);
if dosya then
for i,v in pairs (dosya) do
local tblSplit = String.SplitPath(v)
ListBox.AddItem("list", tblSplit.Filename, v);
end
end


StatusDlg.Hide();
end[/code][/spoiler]
Eğer Son Müzik Bittiğinde Yeniden İlk Baştan Çalmasını İsterseniz

Global

[spoiler][code]function gerial()
item = 1
itemdatasi = ListBox.GetItemData("list", item);
ListBox.DeselectItem("list", -1);
ListBox.SelectItem("list", item);
muzikcal(itemdatasi)
Application.Sleep(2000)
end[/code][/spoiler]

On Timer

[spoiler][code]sure = Label.GetText("süre");
kontrol ="-1:59 / 00:00"

if sure == kontrol then
gerial()
end[/code][/spoiler]
Eğer Müzik Eklendikten Sonra Müziğin Başlamasını İsterseniz[Listboxu Böylece Proje Alanına Koymanız Gerekmez]

Butondaki Kodu Değiştirmeniz Yeterlidir.

[spoiler][code] tblMenu = {};
tblMenu[5] ={};
tblMenu[5].Text = "Aç";
tblMenu[5].ID = 101;
tblMenu[5].IconID = 11;
tblMenu[5].Checked = false;
tblMenu[5].Enabled = true;

tblMenu[4] ={};
tblMenu[4].Text = "Kaydet";
tblMenu[4].ID = 102;
tblMenu[4].IconID = 11;
tblMenu[4].Checked = false;
tblMenu[4].Enabled = true;

tblMenu[1] ={};
tblMenu[1].Text = "Gözat";
tblMenu[1].ID = 104;
tblMenu[1].IconID = 11;
tblMenu[1].Checked = false;
tblMenu[1].Enabled = true;

tblMenu[3] ={};
tblMenu[3].Text = "Temizle";
tblMenu[3].ID = 100;
tblMenu[3].IconID = 11;
tblMenu[3].Checked = false;
tblMenu[3].Enabled = true;

tblMenu[2] ={};
tblMenu[2].Text = "Seçerek Aç";
tblMenu[2].ID = 105;
tblMenu[2].IconID = 11;
tblMenu[2].Checked = false;
tblMenu[2].Enabled = true;

ptMouse = System.GetMousePosition(false, nil);

nRes = Application.ShowPopupMenu(ptMouse.X, ptMouse.Y, tblMenu, TPM_RIGHTALIGN, TPM_TOPALIGN, true, false);

if(nRes == 100)then

Audio.Stop(CHANNEL_BACKGROUND);
ListBox.DeleteItem("list", -1);
Image.SetSize("play", 35, 35);
Image.SetSize("puase", 0, 0);
gerial()
elseif(nRes == 101)then

LoadPlayList("list")
elseif(nRes == 102)then
CreatePlayList("list")


elseif(nRes == 104)then

dosya = Dialog.FolderBrowse("Mp3 Klasörünü seçin", _DesktopFolder)
StatusDlg.Show(0, false);
tblFiles = File.Find(dosya, "*.mp3", true, false, nil, nil);
if tblFiles then
for i,v in pairs (tblFiles) do
local tblSplit = String.SplitPath(v)
ListBox.AddItem("list", tblSplit.Filename, v);
end
end
StatusDlg.Hide();
gerial()
elseif(nRes == 105)then


dosya = Dialog.FileBrowse(true, "Müzik Seçiniz", _DesktopFolder, "Müzik (*.mp3)|*.mp3|", "", "dat", true, false);
StatusDlg.Show(0, false);
if dosya then
for i,v in pairs (dosya) do
local tblSplit = String.SplitPath(v)
ListBox.AddItem("list", tblSplit.Filename, v);
end
end


StatusDlg.Hide();
gerial()
end[/code][/spoiler]

Not:Sorunlarınız Var İse Lütfen Bildiriniz
[/font][/b] Edited by Kral__
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.
Note: Your post will require moderator approval before it will be visible.

Guest
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.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...